<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent changes to Add own log messages</title><link href="https://forge.codesys.com/u/ingo/blog/2019/05/add-own-log-messages/" rel="alternate"/><link href="https://forge.codesys.com/u/ingo/blog/2019/05/add-own-log-messages/feed.atom" rel="self"/><id>https://forge.codesys.com/u/ingo/blog/2019/05/add-own-log-messages/</id><updated>2022-01-28T15:02:31.505000Z</updated><subtitle>Recent changes to Add own log messages</subtitle><entry><title>Add own log messages discussion</title><link href="https://forge.codesys.com/u/ingo/blog/2019/05/add-own-log-messages/?limit=250#c2a7/2fd4/7a8d" rel="alternate"/><published>2022-01-28T15:02:31.505000Z</published><updated>2022-01-28T15:02:31.505000Z</updated><author><name>h-hermsen</name><uri>https://forge.codesys.com/u/hermsen/</uri></author><id>https://forge.codesys.combbdd053b18cdf5b86075ac50ad30242385ee32c0</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;True, but it makes more sense that this code needs to be executed in implicitly available methods:    &lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="err"&gt;    FB_init&lt;/span&gt;
&lt;span class="err"&gt;    FB_reinit&lt;/span&gt;
&lt;span class="err"&gt;    FB_exit&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;If those methods are used, the code will be robust and only called once per triggering event (Init, Re-Init or exit) and can be tailored accordingly.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Add own log messages discussion</title><link href="https://forge.codesys.com/u/ingo/blog/2019/05/add-own-log-messages/?limit=25#c2a7/2fd4" rel="alternate"/><published>2022-01-28T13:40:56.604000Z</published><updated>2022-01-28T13:40:56.604000Z</updated><author><name>andi</name><uri>https://forge.codesys.com/u/andi/</uri></author><id>https://forge.codesys.com4eca826125b7221b9194bb3f9bb548c2c9459ed3</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi, the correct statement should be &lt;br/&gt;
IF udiCmpId &lt;strong&gt;=&lt;/strong&gt; 0 THEN&lt;br/&gt;
so that it will called once at the beginning&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Add own log messages discussion</title><link href="https://forge.codesys.com/u/ingo/blog/2019/05/add-own-log-messages/?limit=25#b0ae" rel="alternate"/><published>2021-08-06T17:33:12.832000Z</published><updated>2021-08-06T17:33:12.832000Z</updated><author><name>sgronchi</name><uri>https://forge.codesys.com/u/sgronchi/</uri></author><id>https://forge.codesys.comc8e7d20e7c9edbc6394dcefbfb1785c7bf721507</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Do you know why DTClogger seems not to work if passed a custom logger with these options?&lt;br/&gt;
    DM1_logOptions : CmpLog.LogOptions :=&lt;br/&gt;
        (szName   := 'J1939_DM1',&lt;br/&gt;
         bEnable  := 1,&lt;br/&gt;
         uiType   := CmpLog.LogTypes.LT_NORMAL OR CmpLog.LogTypes.LT_TIMESTAMP_RTC OR CmpLog.LogTypes.LT_NO_DISABLE OR CmpLog.LogTypes.LT_DUMP_ALWAYS, // LT_DUMP_ASYNC as in LT_STD results in the same&lt;br/&gt;
         uiFilter := CmpLog.LogClass.LOG_INFO OR CmpLog.LogClass.LOG_WARNING OR CmpLog.LogClass.LOG_ERROR OR CmpLog.LogClass.LOG_EXCEPTION,&lt;br/&gt;
         iMaxEntries  :=  1000,&lt;br/&gt;
         iMaxFileSize := 50000,&lt;br/&gt;
         iMaxFiles    := 20);&lt;/p&gt;
&lt;p&gt;'J1939_DM1' log is always empty, but DTCs end up in the device-specific log (I think thanks to DM1 read...)&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Add own log messages discussion</title><link href="https://forge.codesys.com/u/ingo/blog/2019/05/add-own-log-messages/?limit=25#c2a7" rel="alternate"/><published>2020-10-08T11:41:47.448000Z</published><updated>2020-10-08T11:41:47.448000Z</updated><author><name>pcimatti78</name><uri>https://forge.codesys.com/u/pcimatti78/</uri></author><id>https://forge.codesys.comcc9484c0804cd8f9241714e8d5d2c62936f94cb7</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;hi,&lt;br/&gt;
why &amp;lt;&amp;gt;&lt;br/&gt;
IF udiCmpId&lt;strong&gt;&lt;em&gt; &amp;lt;&amp;gt; &lt;/em&gt;&lt;/strong&gt;0 THEN&lt;br/&gt;
    Component_Manager.CMAddComponent2('User Application', 16#00000001, ADR(udiCmpId), 0);&lt;br/&gt;
END_IF&lt;/p&gt;
&lt;p&gt;does this operation be executed only the first time?&lt;/p&gt;
&lt;p&gt;BR, Paolo&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Add own log messages discussion</title><link href="https://forge.codesys.com/u/ingo/blog/2019/05/add-own-log-messages/?limit=25#15f5" rel="alternate"/><published>2020-07-30T19:58:40.053000Z</published><updated>2020-07-30T19:58:40.053000Z</updated><author><name>mr337</name><uri>https://forge.codesys.com/u/mr337/</uri></author><id>https://forge.codesys.com5a3775c03ca8da1e0ffb959b3840a703dceff613</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Dang, thanks for the info!&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Add own log messages discussion</title><link href="https://forge.codesys.com/u/ingo/blog/2019/05/add-own-log-messages/?limit=250#988b" rel="alternate"/><published>2020-07-29T07:27:28.752000Z</published><updated>2020-07-29T07:27:28.752000Z</updated><author><name>aliazzz</name><uri>https://forge.codesys.com/u/aliazzz/</uri></author><id>https://forge.codesys.com8b83da2687883287610b9b40a36b9c87bef4604b</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;I think this example is for SP14 or SP15, you use SP11.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Add own log messages discussion</title><link href="https://forge.codesys.com/u/ingo/blog/2019/05/add-own-log-messages/?limit=25#7fe2" rel="alternate"/><published>2020-07-28T02:34:05.373000Z</published><updated>2020-07-28T02:34:05.373000Z</updated><author><name>mr337</name><uri>https://forge.codesys.com/u/mr337/</uri></author><id>https://forge.codesys.com66db91c93035c30d009433bf60be12b92865231a</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Is the project file corrupted some how? Getting the following when trying to open in CodeSys 3.5 SP11&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Add own log messages discussion</title><link href="https://forge.codesys.com/u/ingo/blog/2019/05/add-own-log-messages/?limit=250#7388" rel="alternate"/><published>2019-05-18T09:01:17.115000Z</published><updated>2019-05-18T09:01:17.115000Z</updated><author><name>aliazzz</name><uri>https://forge.codesys.com/u/aliazzz/</uri></author><id>https://forge.codesys.com7767a1be07c91d06a5d22f1c45b1e1c2f4683df2</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Nice posting! Thank you for this&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Add own log messages</title><link href="https://forge.codesys.com/u/ingo/blog/2019/05/add-own-log-messages/" rel="alternate"/><published>2019-05-10T13:54:57.866000Z</published><updated>2019-05-10T13:54:57.866000Z</updated><author><name>Ingo</name><uri>https://forge.codesys.com/u/ingo/</uri></author><id>https://forge.codesys.com74186a285f3c28123911494e02a1a33b333f3d69</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;div class="dl_button" style="float: right; clear: right;"&gt;
        &lt;p&gt;&lt;a href="/u/ingo/blog/2019/05/add-own-log-messages/attachment/LoggerExample.project"&gt;Download&lt;/a&gt; Example&lt;/p&gt;
        &lt;/div&gt;
&lt;p&gt;CODESYS includes a logger, where system components and fieldbusses are issuing status and error messages.&lt;/p&gt;
&lt;p&gt;&lt;img src="https://forge.codesys.com/u/ingo/blog/2019/05/add-own-log-messages/attachment/Logger.gif"/&gt;&lt;/p&gt;
&lt;p&gt;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.&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;Component_Manager.CMAddComponent2('User Application', 16#00000001, ADR(udiCmpId), 0);
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;After that you can freely issue LogAdd to write new messages to the PLC log.&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;CmpLog.LogAdd2(CmpLog.LOG_STD_LOGGER, udiCmpId, CmpLog.LogClass.LOG_INFO, 1, 1, 'Test Message');
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src="https://forge.codesys.com/u/ingo/blog/2019/05/add-own-log-messages/attachment/ApplicationLogger.gif"/&gt;&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>