Explained how to customise the category of the generated Log(ger)

This commit is contained in:
Maarten Mulders
2014-02-08 21:08:39 +01:00
parent c0e00edb7b
commit 52bb71582b
3 changed files with 18 additions and 0 deletions
+8
View File
@@ -13,3 +13,11 @@ public class LogExampleOther {
log.error("Something else is wrong here");
}
}
public class LogExampleCategory {
private static final org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog("CounterLog");
public static void main(String... args) {
log.error("Calling the 'CounterLog' with a message");
}
}
+8
View File
@@ -16,3 +16,11 @@ public class LogExampleOther {
log.error("Something else is wrong here");
}
}
@CommonsLog("CounterLog")
public class LogExampleCategory {
public static void main(String... args) {
log.error("Calling the 'CounterLog' with a message");
}
}
+2
View File
@@ -33,6 +33,8 @@
<dt><code>@XSlf4j</code></dt>
<dd>Creates <code><span class="keyword">private&nbsp;static&nbsp;final&nbsp;</span><a href="http://www.slf4j.org/api/org/slf4j/ext/XLogger.html">org.slf4j.ext.XLogger</a>&nbsp;<span class="staticfield">log</span>&nbsp;=&nbsp;<a href="http://www.slf4j.org/apidocs/org/slf4j/ext/XLoggerFactory.html#getXLogger(java.lang.Class)">org.slf4j.ext.XLoggerFactory.getXLogger</a>(LogExample.<span class="keyword">class</span>);</code></dd>
</dl>
</p><p>
By default, the category (or name) of the logger will be the type where the annotation was placed. This can be customised by specifying a value for the category.
</p>
</div>
<div class="snippets">