ptv-logistics/Log4ALA

PatternLayout not display few value

Opened this issue · 6 comments

Hi,
I've been using Log4ALA for a few weeks now and I couldn't find a solution to my issue.

This is my appender configuration:

    <appender name="Log4ALASignavioSyncAppender" type="Log4ALA.Log4ALAAppender, Log4ALA" >
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="DateValue=%date;LogId=%property{MessageId};EventType=%property{EventType};Level=%-5level;Logger=%logger;method=%M;message=%message;" />
      </layout>
      <workspaceId value="XXXXXX" />
      <SharedKey value="XXXXX" />
      <logType value="XYZZXCZXCZ" />

      <logMessageToFile value="true"/>
      <disableAnonymousPropsPrefix value="true"/>
      <batchWaitMaxInSec value="300"/>
    </appender>

As you can see I'm using a PatternLayout with some out of the box fields like %M (Method) and a couple of custom fields like MessageId and EventType that I set in my application using the code:

            log4net.ThreadContext.Properties[MessageIdKey] = "xyz";
            log4net.ThreadContext.Properties[EventType] = "abc";

Long story short, I never find these three fields in the Azure log. I tried to add a Console appender and I can see all the fields correctly.

I tried to sniff my app using Fiddler and I can see that these 3 fields are not passed in the request, please see this screenshot:

image

image

What am I doing wrong?

Thanks!

Hi @middiu ,

quick answer ;-) could you see any PatternLayout using in my examples? The answer is no...so Log4ALA doesn't support PatternLayout... you should assign the properties in the log message itself.

Best regards,
Markus

Hi @moberacker ,
thanks for your quick response.

I saw a commented example with PatternLayout in your readme so I though it was support :)

BTW, how hard would it be to implement it? that would be a really big plus. In this was you can leave the JSON format in the PatternLayout and you can simply log the message from your application. How good that would be? :)

Have a think, I think it's worth it

Cheers

Hi @middiu,

the commented example with PatternLayout refers to an LogentriesAppender as error logger (errLoggerName=... ) an optional name of an logger to log internal errors to e.g. logentries.

Using the Diagnostic Context to log additional fields with log4net.ThreadContext.Properties["****"] isn't recommended for high volume logging on a production application...because it could slow down the performance.

Bu I'll think about it.

Best regards,
Markus

not necessarily log4net.ThreadContext.Properties["****"], but for example logging the method name or the class where the log is generated can be really important when troubleshooting. isn't it?

Thanks a lot

I'll take a closer look with the next version

hey mate, how is this going? have you decided if implementing this or not? any ETA?

Thanks a lot!