0

I am working on log4net for the first time and I got it to working. But some of the fields iin the database where I am logging are empty. I want to make use of those. For example FileName (db column) is (null). And I have its parameter set up in config file like this

<parameter>
    <parameterName value="@filename" />
     <dbType value="String" />
     <size value="200" />
     <layout type="log4net.Layout.PatternLayout">
     <conversionPattern value="%X{cFileName}" />
    </layout>
</parameter>

I want to use this above parameter with a dynamic value sent from the asp.net code. And I see this below part as an appender and I am not really sure what this is for. Please suggest. Thanks in advance!!

<conversionPattern value="%d [%t] %-5level %logger%nCustom Message: %X{cMessage}%nSystem Message: %m%n" />
challengeAccepted
  • 7,106
  • 20
  • 74
  • 105
  • How are you setting the value for cFileName? – sgmoore Oct 08 '15 at 12:11
  • @sgmoore I am not sure how can I pass cFileName from the code? Because when logging, All I am sending is a Message and Exception. Ex: logger.LogInfo("Start App", null) or logger.LogError( "Error: , ex). I want to add something like cFileName too. – challengeAccepted Oct 08 '15 at 13:55
  • 1
    See https://stackoverflow.com/questions/12139486/log4net-how-to-add-a-custom-field-to-my-logging?rq=1 – sgmoore Oct 08 '15 at 14:23
  • Very well @sgmoore. I really appreciate the help. This is exactly what I wanted to know. Can you please post your above comment as an answer. I would like to vote it. Thanks a lot – challengeAccepted Oct 09 '15 at 13:45

0 Answers0