You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Jim Moore <ji...@veritas.com> on 2002/06/03 21:03:36 UTC
RE: TRACE level
"In order to make this work I need a logger class as well right?"
In Log4j pre-1.2 the answer was yes, but not anymore. However, in your
properties, you have to specify the class.
For example, in your log4j.properties file:
log4j.logger.HolderLogger=trace#com.mycompany.TraceablePriority
And in your code you do
if (LOGGER.isEnabledFor(TraceablePriority.TRACE))
LOGGER.log(TraceablePriority.TRACE, "My message");
-----Original Message-----
From: Sean Hager [mailto:sean@comaco.com]
Sent: Monday, June 03, 2002 2:51 PM
To: jim.moore@veritas.com
Subject: RE: TRACE level
Thanks for the information Jim.
In order to make this work I need a logger class as well right? would you
be willing to spare your well tested code?
sean.
> -----Original Message-----
> From: Jim Moore [mailto:jim.moore@veritas.com]
> Sent: Monday, June 03, 2002 12:59 PM
> To: 'Log4J Developers List'
> Subject: RE: TRACE level
>
>
> I'll save you some programming:
>
> public class TraceLevel extends Level {
> public static final int TRACE_INT = 800;
>
> // We assimilate TRACE to DEBUG on Syslog
> private static final int SYSLOG_TRACE_INT = 7;
>
> public static final TraceLevel TRACE =
> new TraceLevel(TRACE_INT, "TRACE", SYSLOG_TRACE_INT);
>
> final static public Level ALL = new TraceLevel(ALL_INT, "ALL", 9);
>
> protected TraceLevel(int level, String strLevel, int syslogEquiv) {
> super(level, strLevel, syslogEquiv);
> }
>
> public static Priority toPriority(String sArg) {
> return toPriority(sArg, TraceLevel.TRACE);
> }
>
> public static Priority toPriority(int i) throws
> IllegalArgumentException {
> return toPriority(i, TraceLevel.TRACE);
> }
>
> public static Priority toPriority(int i, Priority priority) {
> Priority p = (i == TRACE_INT) ?
> TraceLevel.TRACE :
> Priority.toPriority(i, priority);
>
> return p;
> }
>
> public static Priority toPriority(String sArg, Priority priority) {
> Priority p = (sArg == null) ?
> TraceLevel.TRACE :
> ((sArg.equalsIgnoreCase("TRACE")) ?
> TraceLevel.TRACE :
> Priority.toPriority(sArg, priority));
>
> return p;
> }
>
> public static Level toLevel(String s) {
> return toLevel(s, TraceLevel.TRACE);
> }
>
> public static Level toLevel(int i) {
> return toLevel(i, TraceLevel.TRACE);
> }
>
> public static Level toLevel(int i, Level level) {
> Level l = (i == TRACE_INT) ?
> TraceLevel.TRACE :
> Level.toLevel(i, level);
>
> return l;
> }
>
> public static Level toLevel(String s, Level level) {
> Level l = (s == null) ?
> TraceLevel.TRACE :
> ((s.equalsIgnoreCase("TRACE")) ?
> TraceLevel.TRACE :
> Level.toLevel(s, level));
>
> return l;
> }
>
> /**
> * @deprecated
> */
> public static Priority[] getAllPossiblePriorities() {
> return new Priority[]{Priority.FATAL, Priority.ERROR, Level.WARN,
> Priority.INFO, Priority.DEBUG, TRACE};
> }
> }
>
> Obviously, I use TRACE levels myself. This topic keeps coming up, and
> it's constantly disagreed with (largely for reasons of not cluttering
> the namespace of available levels -- see discussion regarding issues
> with JSR47...).
>
>
> -----Original Message-----
> From: Sean Hager [mailto:sean@comaco.com]
> Sent: Monday, June 03, 2002 1:52 PM
> To: log4j-dev@jakarta.apache.org
> Subject: TRACE level
>
>
> Before I subclass the level class and add in a TRACE level, is there
> any chance log4j will add in a TRACE level?
>
>
> I really see the need to have a TRACE level that just details path of
> the program without cluttering up the DEBUG level output.
>
> Sean.
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>