The Log4Net mailing list is a great source of information about using log4Net, in this forum we collect all the messages in the log4net user list and some selected threads from the developer list.
| Author |
Messages |
|
Laxmilal Menaria
 |
| 12/15/2007 12:25 PM |
|
Hello,
I am asp.net user, and want to store IP address in Log4Net logs, I am using RollingFileAppender, so how can I enable IP logging with conversion pattern.
Please let me know, how its is possible ?
Thanks in advance, Laxmilal
|
|
|
|
|
Johnson, Cedrick
 |
| 12/17/2007 4:29 PM |
|
You could set it by Application level context. I have configured hostname logging by doing the following (I'm sure there is a method in System.Net to find the IP address, similar to the hostname)
In your code:
log4net.GlobalContext.Properties["Hostname"] = Dns.GetHostName();
In the RollingLogFileAppender's layout/ConversionPattern section:
<layout type="log4net.Layout.PatternLayout"> <conversionPattern value="%date %property{Hostname} [%thread] %-5level %logger - %message%newline" /> </layout>
Hope this helps, CJ
|
|
|
|
|
Laxmilal Menaria
 |
| 12/18/2007 5:20 AM |
|
ok..thanks..
|
|
|
|
|
Laxmilal Menaria
 |
| 01/14/2009 8:23 AM |
|
Its working at application Level but if at the same time any other user will come to site. Then this property value is changed so logs show the latest value. (I have set this property at session start).
So is there any other configuration to do this? because too many users will visit the site at same time.
Please let me know.
Thanks, Laxmilal -- View this message in context: http://www.nabble.com/How-to-enable-IP-address-logging-with-Log4Net-configuration-tp14349967p21451120.html Sent from the Log4net - Users mailing list archive at Nabble.com.
|
|
|
|
|
|
| You are not authorized to post a reply. |
|
|
|
ActiveForums 3.7
|