Reputation: 390
I would like to log class names (excluding package prefix) as well as methods in the following way:
<className>.<methodName>
Currently my xml layout for this is
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %5p [%t] (%F.%M) - %m%n" />
</layout>
which returns a filename that includes the .java file type.
Is there some way to configure log4j so that it will remove the .java from the filename?
Upvotes: 1
Views: 119
Reputation: 4347
If what you want is the class name, then you should consider the %C conversion character, as described in the Javadoc for PatternLayout.
For instance, to specify the unqualified class name:
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %5p [%t] (%C{1}.%M) - %m%n" />
</layout>
Note the usage of the {1} qualifier, which designates the first rightmost component of the fully qualified class name.
Upvotes: 1