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]



Re: Parsing problem

2008-02-20 Thread osubb

I tried it, but still getting the same error.



Jim Reilly-2 wrote:
> 
> 
> 
> Try the xml below.
> A few problems.  The renderer tag needs to be empty (per DTD), so need to
> close the tag in same tag  (not use a ).
> 
> Also I think order matters, so need to keep in this order: 
> renderer*, appender*,(category|logger)*,root?, categoryFactory?
> 
> -Jim
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> renderingClass="com.firstpac.etools.log.HttpServletRequestRenderer"/>
> 
> 
>  class="org.apache.log4j.DailyRollingFileAppender">
> 
> 
> 
> 
> 
>  class="org.apache.log4j.jdbc.JDBCAppender">
> 
> 
> 
> 
>     
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> - Original Message 
> From: osubb <[EMAIL PROTECTED]>
> To: log4j-user@logging.apache.org
> Sent: Tuesday, February 19, 2008 2:23:12 PM
> Subject: Parsing problem
> 
> 
> 
> I 
> seem 
> to 
> get 
> warning 
> whenever 
> log4j 
> configure 
> file 
> is 
> loaded.  
> I 
> looked 
> at
> my 
> config 
> file 
> and 
> can 
> see 
> no 
> syntax 
> problems.  
> Can 
> somebody 
> point 
> me 
> in 
> the
> right 
> direction???
> 
> 
> WARNINGS*
> log4j:WARN 
> Continuable 
> parsing 
> error 
> 50 
> and 
> column 
> 13
> log4j:WARN 
> The 
> content 
> of 
> element 
> type 
> "renderer" 
> must 
> match 
> "EMPTY".
> log4j:WARN 
> Continuable 
> parsing 
> error 
> 53 
> and 
> column 
> 23
> 
>  
> CONFIG 
> FILE 
> 
> 
>  version="1.0" 
> encoding="UTF-8"?>
>  log4j:configuration 
> SYSTEM 
> "log4j.dtd">
> 
>  xmlns:log4j="http://jakarta.apache.org/log4j/";>
> 
> 
> 
> 
> 
> 
>  name="com.firstpac.etools.log4j.log">
> 
> 
>  value="debug"/>
> 
> 
>  ref="log"/>
> 
> 
> 
> 
> 
> 
> 
> 
>  name="com.firstpac.etools.log4j.clientStats">
> 
> 
>  value="info"/>
> 
> 
>  ref="clientStats"/>
> 
> 
> 
> 
> 
> 
>  name="log" 
> class="org.apache.log4j.DailyRollingFileAppender">
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
>  class="org.apache.log4j.PatternLayout">
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
>  name="clientStats" 
> class="org.apache.log4j.jdbc.JDBCAppender" 
>>
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
>  renderedClass="javax.servlet.http.HttpServletRequest"
> 
> 
> renderingClass="com.firstpac.etools.log.HttpServletRequestRenderer" 
>>
> 
> 
> 
> 
> 
> 
> -- 
> View 
> this 
> message 
> in 
> context: 
> http://www.nabble.com/Parsing-problem-tp15562410p15562410.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]
> 
> 
> 
> 
> 
> 
> 
>  
> 
> Never miss a thing.  Make Yahoo your home page. 
> http://www.yahoo.com/r/hs
> 

-- 
View this message in context: 
http://www.nabble.com/Parsing-problem-tp15562410p15598158.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]



Parsing problem

2008-02-19 Thread osubb

I seem to get warning whenever log4j configure file is loaded.  I looked at
my config file and can see no syntax problems.  Can somebody point me in the
right direction???


WARNINGS*
log4j:WARN Continuable parsing error 50 and column 13
log4j:WARN The content of element type "renderer" must match "EMPTY".
log4j:WARN Continuable parsing error 53 and column 23

 CONFIG FILE 




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













































-- 
View this message in context: 
http://www.nabble.com/Parsing-problem-tp15562410p15562410.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]



Re: dynamic variables/parameters

2008-02-14 Thread osubb

I need to use the xml version.  Also, please read my reply to the previous
response I got.  I think it applies.

Again, I need a way to change the values for each new client connection
(servlet thread).  I don't think reloading the properties for each thread is
the way to go (although this seems to be the only solution that might work
at this point - if I don't use the xml config).


thanks for the help,  any other ideas?

osubb


Maarten Bosteels wrote:
> 
> When you use a log4j.properties file instead of log4j.xml
> you can use
> http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/PropertyConfigurator.html#configure(java.util.Properties)
> 
> 1) load the log4j.properties file in a Properties object
> 2) add all custom properties to the Properties object
> 3) call PropertyConfigurator.configure(props)
> 
> I have no idea if something similar can be done with the DOMConfigurator.
> You could search the ml archive, this question has come up more than once.
> 
> Maarten
> 
> On Thu, Feb 14, 2008 at 12:23 AM, 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]
>>
>>
> 
> 

-- 
View this message in context: 
http://www.nabble.com/dynamic-variables-parameters-tp15470530p15481257.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]



Re: dynamic variables/parameters

2008-02-14 Thread osubb

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]



dynamic variables/parameters

2008-02-13 Thread osubb

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]