tags:

views:

368

answers:

4

I'm having a hard time finding documentation on the various 'in the box' patterns like %logger %level %timestamp

There is of course the example page but I'm not sure that's the full list of options.

I also know that it's possible to MDC parameters out of the app to the logger, but that involves a code change which is a different beast than a config change.

Is there a %machineName option, or machineIP option? The issue is that we have all our servers in the web farm log into the same database log, and we're now thinking that a disproportionate number of messages are coming from one machine.

+1  A: 

Check out the PatternString API, it looks like you would need to use %property in your pattern. Also take a look at this article, you may need to inject the machine name into the global context on application startup.

AgileJon
@AgileJon -- that article was exactly what I was looking for! Thank you!!!
James Schek
+1  A: 
%property{log4net:HostName}
JC
+1  A: 

What I did just stumble across is

<layout type="log4net.Layout.PatternLayout" value="${COMPUTERNAME}"/>

and that seems to be working --- wonder what the difference is between this and the other options suggested. like %property{log4net:HostName}

Ralph Shillington
${...} depends on environment variables.
Peter Lillevold
A: 

Interesting, I think this is the "Compact Parameter Syntax" check out the last section over here http://logging.apache.org/log4net/release/manual/configuration.html

Binder