Re: dynamic variables/parameters

2008-02-21 Thread osubb

I don't anymore.  I am pretty new to log4j and started a new project where I
figured it would be nice to be able to have data logged to different tables
based on who the client was.  Not the best way to do it, but I was wondering
if there was a way to do this.  Now thinking about it, probably not what
log4j is used for.  To do this I would probably have to reload the log4j
config file for each thread (and not sure if that would cause threading
issues).

I did figure out how to load parameters into the log4j thanks to all the
help from everyone.  I will be setting up java's System properties, and then
reloading the config file once.

Thanks for all the help

osubb


James A. N. Stauffer wrote:
> 
> It might help if you could provide more details on why you want the
> JDBC parameters to vary per connection/thread.
> 
> On Thu, Feb 14, 2008 at 10:15 AM, osubb <[EMAIL PROTECTED]> wrote:
>>
>>  I don't believe this will work.  The system properties are set once the
>>  Servlet is started.  I will have different parameters for each new
>>  connection (thread) of the servlet.  I need a way to alter the values
>> for
>>  each thread.  I thought of using MDC, but that only worked when using
>> the
>>  "ConversionPatter" or using the "sql" param for JDBCAppender.
>>
>>  Is there any way to pass in values to log4j for each client connection
>>  (Servlet thread)??
>>
>>  thanks,
>>
>>  osubb
>>
>>
>>
>>
>>
>>  James A. N. Stauffer wrote:
>>  >
>>  > In an XML config, system properties can be used like ${catalina.base}.
>>  >
>>  > On Wed, Feb 13, 2008 at 5:23 PM, osubb <[EMAIL PROTECTED]> wrote:
>>  >>
>>  >>  I am pretty new to log4j and have a question that should be easy.  I
>> am
>>  >> using
>>  >>  log4j in a web (java servlets) environment.
>>  >>
>>  >>  1)  How do I pass in variables?  I have an app that uses the
>>  >> JDBCAppender
>>  >>  and would like to pass in the connection values.  Is there an easy
>> way
>>  >> to do
>>  >>  this?  These values could be different for each client that access
>> the
>>  >>  Servlet(s).  Is there a pattern for this type of scenario?
>>  >>
>>  >>  At this point, I have to hardcode the URL, user, and password values
>> in
>>  >> the
>>  >>  log4j.xml file.  I tried using MDC, but this seems to work in the
>>  >>  "ConversionPattern" param for log files and the "sql" param name for
>> the
>>  >>  JDBCAppender.  It does not work for the "URL", "user", and
>> "password"
>>  >> param
>>  >>  values (does not change to MDC value).
>>  >>
>>  >>  Any help would be appreciated,
>>  >>  osubb
>>  >>  --
>>  >>  View this message in context:
>>  >>
>> http://www.nabble.com/dynamic-variables-parameters-tp15470530p15470530.html
>>  >>  Sent from the Log4j - Users mailing list archive at Nabble.com.
>>  >>
>>  >>
>>  >> 
>> -
>>  >>  To unsubscribe, e-mail: [EMAIL PROTECTED]
>>  >>  For additional commands, e-mail: [EMAIL PROTECTED]
>>  >>
>>  >>
>>  >
>>  >
>>  >
>>  > --
>>  > James A. N. Stauffer http://www.geocities.com/stauffer_james/
>>  > Are you good? Take the test at http://www.livingwaters.com/good/
>>  >
>>  > -
>>  > To unsubscribe, e-mail: [EMAIL PROTECTED]
>>  > For additional commands, e-mail: [EMAIL PROTECTED]
>>  >
>>  >
>>  >
>>
>>  --
>>  View this message in context:
>> http://www.nabble.com/dynamic-variables-parameters-tp15470530p15481252.html
>>
>>
>> Sent from the Log4j - Users mailing list archive at Nabble.com.
>>
>>
>>  -
>>  To unsubscribe, e-mail: [EMAIL PROTECTED]
>>  For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
> 
> 
> 
> -- 
> James A. N. Stauffer http://www.geocities.com/stauffer_james/
> Are you good? Take the test at http://www.livingwaters.com/good/
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/dynamic-variables-parameters-tp15470530p15625193.html
Sent from the Log4j - Users mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



SV: SV: log4j Guidelines

2008-02-21 Thread Cosette Kamakian
Thank you very very much for the help. It working yippii :)

Good night 
Cheers
cosette 

-Ursprungligt meddelande-
Från: Curt Arnold [mailto:[EMAIL PROTECTED] 
Skickat: den 22 februari 2008 00:02
Till: Log4J Users List
Ämne: Re: SV: log4j Guidelines


On Feb 21, 2008, at 4:38 PM, Cosette Kamakian wrote:

> The problem it is still their. Received the same error
>

If you are still getting this error:

log4j:WARN Fatal parsing error 2 and column 6
log4j:WARN The processing instruction target matching "[xX][mM][lL]"  
is not allowed.
log4j:ERROR Could not parse url [file:/D:/WS/Inca_Dev/Inca/AppROOT/WEB- 
INF/classes/log4j.xml].
org.xml.sax.SAXParseException: The processing instruction target  
matching "[xX][mM][lL]" is not allowed.


Then the XML parser provided by the JDK is telling you very precisely  
that your file contains a "

  
  
  
-
+
+

  
  
  
-
+

  
  
  
  


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: SV: log4j Guidelines

2008-02-21 Thread Curt Arnold


On Feb 21, 2008, at 4:38 PM, Cosette Kamakian wrote:


The problem it is still their. Received the same error



If you are still getting this error:

log4j:WARN Fatal parsing error 2 and column 6
log4j:WARN The processing instruction target matching "[xX][mM][lL]"  
is not allowed.
log4j:ERROR Could not parse url [file:/D:/WS/Inca_Dev/Inca/AppROOT/WEB- 
INF/classes/log4j.xml].
org.xml.sax.SAXParseException: The processing instruction target  
matching "[xX][mM][lL]" is not allowed.



Then the XML parser provided by the JDK is telling you very precisely  
that your file contains a "first byte of the file.


There are also two missing end-tags in the document as seen in this  
diff:


--- log4j.xml   2008-02-21 16:59:40.0 -0600
+++ log4j.fixed 2008-02-21 16:59:12.0 -0600
@@ -91,16 +91,17 @@
 

 
 
 
-
+
+

 
 
 
-
+

 
 
 
 


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



SV: log4j Guidelines

2008-02-21 Thread Cosette Kamakian
Thanks for the help , but that didn't help either.

// cosette

-Ursprungligt meddelande-
Från: Matthew Kemp [mailto:[EMAIL PROTECTED] 
Skickat: den 21 februari 2008 23:46
Till: Log4J Users List
Ämne: Re: log4j Guidelines

Try moving your 'ASYNC' appender definition after all the other appender
definitions. This might be causing your error as none of the other appenders
have been created yet.

Also as a side note, I'd recommend using  instead of .

Matt



2008/2/21 Cosette Kamakian <[EMAIL PROTECTED]>:

> The problem it is still their. Received the same error
>
> -Ursprungligt meddelande-
> Från: Curt Arnold [mailto:[EMAIL PROTECTED]
> Skickat: den 21 februari 2008 23:28
> Till: Log4J Users List
> Ämne: Re: log4j Guidelines
>
>
> On Feb 21, 2008, at 4:01 PM, Cosette Kamakian wrote:
>
> > To whom it may concen
> >
> > I 'm a beginner in using Log4j and I thought if you had the
> > possibility to help me with a little problem . I'm using the book
> > the complete log4j manual for my aid. I got a mission to use log4j
> > for our logging. In the beginning when I logged with the help of
> > log4j.properties I didn't receive any error but know when  I need
> > to use asyncAppender  so I converted log4j.properties to log4j.xml
> > and I got a problem .  I receive the following error
> >
>
> In any XML file, the XML declaration has to be there very, very first
> thing in the file since it is used to determine the character
> encoding, etc.  Your file starts with a line feed.
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>





























	













	













	
















  
 
 
 

 
 
 
 

 
 
 
 

 
 
 
 

 
 
 
















 
  
  
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Re: log4j Guidelines

2008-02-21 Thread Matthew Kemp
Try moving your 'ASYNC' appender definition after all the other appender
definitions. This might be causing your error as none of the other appenders
have been created yet.

Also as a side note, I'd recommend using  instead of .

Matt



2008/2/21 Cosette Kamakian <[EMAIL PROTECTED]>:

> The problem it is still their. Received the same error
>
> -Ursprungligt meddelande-
> Från: Curt Arnold [mailto:[EMAIL PROTECTED]
> Skickat: den 21 februari 2008 23:28
> Till: Log4J Users List
> Ämne: Re: log4j Guidelines
>
>
> On Feb 21, 2008, at 4:01 PM, Cosette Kamakian wrote:
>
> > To whom it may concen
> >
> > I 'm a beginner in using Log4j and I thought if you had the
> > possibility to help me with a little problem . I'm using the book
> > the complete log4j manual for my aid. I got a mission to use log4j
> > for our logging. In the beginning when I logged with the help of
> > log4j.properties I didn't receive any error but know when  I need
> > to use asyncAppender  so I converted log4j.properties to log4j.xml
> > and I got a problem .  I receive the following error
> >
>
> In any XML file, the XML declaration has to be there very, very first
> thing in the file since it is used to determine the character
> encoding, etc.  Your file starts with a line feed.
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>


SV: log4j Guidelines

2008-02-21 Thread Cosette Kamakian
The problem it is still their. Received the same error

-Ursprungligt meddelande-
Från: Curt Arnold [mailto:[EMAIL PROTECTED] 
Skickat: den 21 februari 2008 23:28
Till: Log4J Users List
Ämne: Re: log4j Guidelines


On Feb 21, 2008, at 4:01 PM, Cosette Kamakian wrote:

> To whom it may concen
>
> I 'm a beginner in using Log4j and I thought if you had the  
> possibility to help me with a little problem . I'm using the book  
> the complete log4j manual for my aid. I got a mission to use log4j  
> for our logging. In the beginning when I logged with the help of  
> log4j.properties I didn't receive any error but know when  I need   
> to use asyncAppender  so I converted log4j.properties to log4j.xml  
> and I got a problem .  I receive the following error
>

In any XML file, the XML declaration has to be there very, very first  
thing in the file since it is used to determine the character  
encoding, etc.  Your file starts with a line feed.
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]








































	













	













	






  
 
 
 

 
 
 
 

 
 
 
 

 
 
 
 

 
 
 
















 
  
  
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Re: log4j Guidelines

2008-02-21 Thread Curt Arnold


On Feb 21, 2008, at 4:01 PM, Cosette Kamakian wrote:


To whom it may concen

I ’m a beginner in using Log4j and I thought if you had the  
possibility to help me with a little problem . I’m using the book  
the complete log4j manual for my aid. I got a mission to use log4j  
for our logging. In the beginning when I logged with the help of  
log4j.properties I didn’t receive any error but know when  I need   
to use asyncAppender  so I converted log4j.properties to log4j.xml  
and I got a problem .  I receive the following error




In any XML file, the XML declaration has to be there very, very first  
thing in the file since it is used to determine the character  
encoding, etc.  Your file starts with a line feed.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



log4j Guidelines

2008-02-21 Thread Cosette Kamakian
To whom it may concen

 

I 'm a beginner in using Log4j and I thought if you had the possibility to help 
me with a little problem . I'm using the book the complete log4j manual for my 
aid. I got a mission to use log4j for our logging. In the beginning when I 
logged with the help of log4j.properties I didn't receive any error but know 
when  I need  to use asyncAppender  so I converted log4j.properties to 
log4j.xml and I got a problem .  I receive the following error

 

log4j:WARN Fatal parsing error 2 and column 6

log4j:WARN The processing instruction target matching "[xX][mM][lL]" is not 
allowed.

log4j:ERROR Could not parse url 
[file:/D:/WS/Inca_Dev/Inca/AppROOT/WEB-INF/classes/log4j.xml].

org.xml.sax.SAXParseException: The processing instruction target matching 
"[xX][mM][lL]" is not allowed.

 at 
org.apache.xerces.parsers.DOMParser.parse(Unknown Source)

 at 
org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)

 at 
javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:146)

 at 
org.apache.log4j.xml.DOMConfigurator$2.parse(DOMConfigurator.java:690)

 at 
org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:789)

 at 
org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:696)

 at 
org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:471)

 at 
org.apache.log4j.LogManager.(LogManager.java:125)

 at 
org.apache.log4j.Logger.getLogger(Logger.java:105)

 at 
org.apache.commons.logging.impl.Log4JLogger.getLogger(Log4JLogger.java:283)

 at 
org.apache.commons.logging.impl.Log4JLogger.(Log4JLogger.java:108)

 at 
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

 at 
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)

 at 
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)

 at 
java.lang.reflect.Constructor.newInstance(Constructor.java:494)

 at 
org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:529)

 at 
org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:235)

 at 
org.apache.commons.logging.LogFactory.getLog(LogFactory.java:370)

 at 
org.apache.catalina.core.ContainerBase.getLogger(ContainerBase.java:380)

 at 
org.apache.catalina.core.StandardContext.start(StandardContext.java:4114)

 at 
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:759)

 at 
org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:739)

 at 
org.apache.catalina.core.StandardHost.addChild(StandardHost.java:524)

 at 
org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:608)

 at 
org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:535)

 at 
org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:470)

 at 
org.apache.catalina.startup.HostConfig.start(HostConfig.java:1122)

 at 
org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:310)

 at 
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)

 at 
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1021)

 at 
org.apache.catalina.core.StandardHost.start(StandardHost.java:718)

 at 
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1013)

 at 
org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442)

 at 
org.apache.catalina.core.StandardService.start(StandardService.java:450)

 at 
org.apache.catalina.core.StandardServer.start(StandardServer.java:709)

 at 
org.apache.catalina.startup.Catalina.start(Catalina.java:551)

 at 
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

 at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

 at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)


Re: Different levels to different appenders

2008-02-21 Thread Jim Reilly
Mikael,

I think your main problem here is that you cannot put the same logger name 
="xxx"  and have that xxx be the same string, to be able to seperate by logging 
level.I think your only way would be to have multiple appenders that each 
have their own log file that are by log level.

This is the way to log org (3rd party) to Error for MAIN_LOG and INFO to DEBUG 
LEVEL:






















































-Jim

- Original Message 
From: Mikael Ståldal <[EMAIL PROTECTED]>
To: log4j-user@logging.apache.org
Sent: Thursday, February 21, 2008 7:00:36 AM
Subject: Different levels to different appenders


I 
have 
two 
appenders, 
MAIN_LOG 
and 
DEBUG_LOG. 
I 
have 
the 
loggers 
set 
up 
to 
match 
Java 
class 
hierarchy 
as 
recommended. 
I 
have 
two 
interesting 
codebases, 
"com.mycompany" 
and 
"com.othercompany".

I 
want 
to 
send 
DEBUG 
and 
higher 
from 
"com.mycompany" 
and 
WARN 
and 
higher 
from 
"com.othercompany" 
to 
MAIN_LOG. 
And 
I 
want 
to 
send 
DEBUG 
and 
higher 
from 
"com.mycompany" 
and 
DEBUG 
and 
higher 
from 
"com.othercompany" 
to 
DEBUG_LOG.

Finally 
I 
want 
to 
handle 
stuff 
outside 
"com.mycompany" 
or 
"com.othercompany" 
(such 
as 
"org.thirdparty") 
by 
sending 
ERROR 
and 
higher 
to 
MAIN_LOG 
and 
INFO 
and 
higher 
to 
DEBUG_LOG.

How 
do 
I 
accomplish 
that?


-
To 
unsubscribe, 
e-mail: 
[EMAIL PROTECTED]
For 
additional 
commands, 
e-mail: 
[EMAIL PROTECTED]







  

Never miss a thing.  Make Yahoo your home page. 
http://www.yahoo.com/r/hs

Re: Different levels to different appenders

2008-02-21 Thread Jim Reilly
Mikael,

Ooop, I was in a rust 2 days ago when I copied the xml text into the email, I 
left out the  line of xml.

So, here is the full xml and I also attached an xml file just so no tabs or 
extra spaces of < chars get placed in it...

Let me know how this works for you.  The original problem was the black space 
(whitespace really) before the  tag, and also the order of your 
tags.  If you look at your dtd  (log4j.dtd), you'll see this line:



which means that the tags must be in this order, and you had renderer at the 
end, where it needs to be first.  Also, I had to switch your loggers and 
appenders around.

Here is a good site on DTD's:http://www.w3schools.com/dtd/default.asp
This page in the site talked about sequences (order): 
http://www.w3schools.com/dtd/dtd_elements.asp

Here are good log4j info sites:
http://www.vipan.com/htdocs/log4jhelp.html
http://wiki.apache.org/logging-log4j/Log4jXmlFormat



Here is that XML:





































-Jim Reilly






- Original Message 
From: Mikael Ståldal <[EMAIL PROTECTED]>
To: log4j-user@logging.apache.org
Sent: Thursday, February 21, 2008 7:00:36 AM
Subject: Different levels to different appenders


I 
have 
two 
appenders, 
MAIN_LOG 
and 
DEBUG_LOG. 
I 
have 
the 
loggers 
set 
up 
to 
match 
Java 
class 
hierarchy 
as 
recommended. 
I 
have 
two 
interesting 
codebases, 
"com.mycompany" 
and 
"com.othercompany".

I 
want 
to 
send 
DEBUG 
and 
higher 
from 
"com.mycompany" 
and 
WARN 
and 
higher 
from 
"com.othercompany" 
to 
MAIN_LOG. 
And 
I 
want 
to 
send 
DEBUG 
and 
higher 
from 
"com.mycompany" 
and 
DEBUG 
and 
higher 
from 
"com.othercompany" 
to 
DEBUG_LOG.

Finally 
I 
want 
to 
handle 
stuff 
outside 
"com.mycompany" 
or 
"com.othercompany" 
(such 
as 
"org.thirdparty") 
by 
sending 
ERROR 
and 
higher 
to 
MAIN_LOG 
and 
INFO 
and 
higher 
to 
DEBUG_LOG.

How 
do 
I 
accomplish 
that?


-
To 
unsubscribe, 
e-mail: 
[EMAIL PROTECTED]
For 
additional 
commands, 
e-mail: 
[EMAIL PROTECTED]







  

Never miss a thing.  Make Yahoo your home page. 
http://www.yahoo.com/r/hs


http://jakarta.apache.org/log4j/";>

	
	
	

	
	
		
	

	
	


	
	
	
		
		
	

	
	
	
		
		
	



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Different levels to different appenders

2008-02-21 Thread Mikael Ståldal
I have two appenders, MAIN_LOG and DEBUG_LOG. I have the loggers set up to match Java class 
hierarchy as recommended. I have two interesting codebases, "com.mycompany" and 
"com.othercompany".


I want to send DEBUG and higher from "com.mycompany" and WARN and higher from 
"com.othercompany" to MAIN_LOG. And I want to send DEBUG and higher from "com.mycompany" and 
DEBUG and higher from "com.othercompany" to DEBUG_LOG.


Finally I want to handle stuff outside "com.mycompany" or "com.othercompany" (such as 
"org.thirdparty") by sending ERROR and higher to MAIN_LOG and INFO and higher to DEBUG_LOG.


How do I accomplish that?


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]