James Stauffer <stauffer.james <at> gmail.com> writes:
>
> AFAIK there is no way to set it in the config file so one way to set
> it is to call MDC.put("server", serverName) at the beginning of every
> doGet or doPost. Another option may be to have the socket server call
> MDC.put("server", clientName) but I haven't tried that option.
>
> On 12/4/06, Bence Takács <takacs.bence <at> gmail.com> wrote:
> > Hello
> >
> > I'm sorry, I haven't used MDC before. How can I set it from the config
> > (properties, or xml) file?
> >
> > What do you mean "at the beginning of every servlet call"? You mean
> > that all my servlet has to set MDC in the doGet(), and doPost()
> > methods? Could you write an example code?
> >
> > Thanks:
> > Bence
> >
> > On 12/4/06, James Stauffer <stauffer.james <at> gmail.com> wrote:
> > > If you set the MDC at the beginning of every servlet call then most
> > > errors will have it set.
> > >
> > > On 12/4/06, Bence Takács <takacs.bence <at> gmail.com> wrote:
> > > > Hello
> > > >
> > > > Could you express, what do you mean? In the documentation there is no
> > > > example for managing MDC-s from config files (only for reading them).
> > > > But I cannot change tomcat's codes, i can change it's logging
> > > > properties from the logging.properties, or xml file.
> > > >
> > > > Could you help me, how can I manage MDC through this kinds of config
files?
> > > >
> > > > Thanks:
> > > > Bence
> > > >
> > > >
> > > > On 12/4/06, Blok, Eelke <eelke.blok <at> numico.com> wrote:
> > > > > I don't have experience with Log4J in Tomcat, but the usual solution
is to make sure the originating
> server is in an MDC field. This may well be taken care of in your setup
already.
> > > > >
> > > > > -----Original Message-----
> > > > > From: Bence Takács [mailto:takacs.bence <at> gmail.com]
> > > > > Sent: maandag 4 december 2006 13:33
> > > > > To: log4j-user <at> logging.apache.org
> > > > > Subject: Change the log hierarchy on a log server
> > > > >
> > > > >
> > > > > Hello
> > > > >
> > > > > I have a log server (SimpleSocketServer), which gathers all the
log4j clients log. All the clients use
> their application specific settings, and a root logger (in ERROR level) to
catch tomcat Exceptions.
> > > > >
> > > > > To the server the log hierarchy is like this:
mycountry.mycompany.myapplication1
> > > > > mycountry.mycompany.myapplication2
> > > > > mycountry.mycompany.myapplication3
> > > > > org.apache.catalina
> > > > >
> > > > > In this way if I get a tomcat error, I don't know which server was
the source of the exception.
> > > > >
> > > > > Does any way to change the logging hierarchy like this:
myserver1.mycountry.mycompany.myapplication1
> > > > > myserver1.org.apache.catalina
myserver2.mycountry.mycompany.myapplication2
> > > > > myserver2.org.apache.catalina
myserver3.mycountry.mycompany.myapplication3
> > > > > myserver3.org.apache.catalina
> > > > >
> > > > > Thanks:
> > > > > Bence
Hi
As per your suggestion I used MDC as follows :
In the java file , i simply say:
MDC.put("SERVER_HOSTNAME_KEY", "strServerHostname");
In the Configuration properties file, the pattern is cchanged to -
log4j.appender.stdout.layout.ConversionPattern=%X{SERVER_HOSTNAME_KEY} - %5p [%
t] (%F:%L) - %m%n
But the MDC messages are not coming up in the logs. I get the following
output -
- DEBUG [main] (sendLog.java:42) - Hello world
Can you provide me some pointers to it?
Thanx
Deepika
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]