Add own log messages

Download Example

CODESYS includes a logger, where system components and fieldbusses are issuing status and error messages.

But this functionality is not limited to internal features. Every application and every library has access to the logger. You simply need to register a component, that you can identify yourself against the logger.

Component_Manager.CMAddComponent2('User Application', 16#00000001, ADR(udiCmpId), 0);

After that you can freely issue LogAdd to write new messages to the PLC log.

CmpLog.LogAdd2(CmpLog.LOG_STD_LOGGER, udiCmpId, CmpLog.LogClass.LOG_INFO, 1, 1, 'Test Message');

Posted by Ingo 2019-05-10 Labels: 00000001
  • aliazzz

    aliazzz - 2019-05-18

    Nice posting! Thank you for this

  • mr337

    mr337 - 2020-07-28

    Is the project file corrupted some how? Getting the following when trying to open in CodeSys 3.5 SP11

  • aliazzz

    aliazzz - 2020-07-29

    I think this example is for SP14 or SP15, you use SP11.

  • mr337

    mr337 - 2020-07-30

    Dang, thanks for the info!


Log in to post a comment.