logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Extra Extra <made4gene...@yahoo.com>
Subject Re: Custom Conversion character
Date Wed, 01 Mar 2006 03:57:17 GMT
  Again confusion,
  i dont have code level access to any of the classes of my application.
  where do i put this MDC code.
  i have just extended few classes from log4j and make jar file and i want to refer that CustomLogger
and CustomLayouts from my property file.
  but the problem is that my application(in code) is creating object of Original logger instead
of CustomLogger and PropertyConfigurator instead of customPropConfigurator
  i cant alter code and i have only property file threw which i can configure.
  how do i override original Logger with my CustomLogger using property file.
  is there any other classes i need to extend?????
  i am new to log4j. so please if possible state it in detail, 

James Stauffer <stauffer.james@gmail.com> wrote:
  Use MDC.
In code set the value with MDC.put("GUID", value) and then you can use
%X{GUID} in your config file.

On 2/28/06, Extra Extra wrote:
> HI
> I want to add my custom conversion character in to log message.say GUID as %S
> for that i have extended Logger,LoggerFactory,LoggingEvent,RollingFileAppender,
> PatternLayout,PatternParser,PatternConverter,PropertyConfigurator.
> My problem is i have few component which are using log4j and use property file for configuration.but
i have no code level access to those classes.
> when i run my application it is not showing value for my custom attribute(i have given
some default values)
> It is not giving me any kind of error.
> what should i do :- please guide me,
> my property file looks like
> log4j.rootLogger=DEBUG,ROOT
> log4j.logger=org.apache.log4j.test.CustomLogger
> log4j.appender.ROOT=org.apache.log4j.test.CustomRollingFileAppender
> log4j.appender.ROOT.File=C:/PropTest.log
> log4j.appender.ROOT.MaxFileSize=1000KB
> log4j.appender.ROOT.layout=org.apache.log4j.test.CustomPatternLayout
> log4j.appender.ROOT.layout.ConversionPattern=%n--------------------%nTime: %d%nGUID:
%S%nMessage: %m
> %S is my custom character
> thanks in advance
> ---------------------------------
> Brings words and photos together (easily) with
> PhotoMail - it's free and works with Yahoo! Mail.

James Stauffer
Are you good? Take the test at http://www.livingwaters.com/good/

To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org

Yahoo! Mail
Bring photos to life! New PhotoMail  makes sharing a breeze. 
  • Unnamed multipart/alternative (inline, 8-Bit, 0 bytes)
View raw message