Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PatternLayout not display few value #15

Open
middiu opened this issue Feb 24, 2019 · 6 comments
Open

PatternLayout not display few value #15

middiu opened this issue Feb 24, 2019 · 6 comments

Comments

@middiu
Copy link

middiu commented Feb 24, 2019

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!

@moberacker
Copy link
Member

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

@middiu
Copy link
Author

middiu commented Feb 24, 2019

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

@moberacker
Copy link
Member

moberacker commented Feb 25, 2019

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

@middiu
Copy link
Author

middiu commented Feb 25, 2019

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

@moberacker
Copy link
Member

I'll take a closer look with the next version

@middiu
Copy link
Author

middiu commented Mar 29, 2019

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

Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants