Re: ms sql server and log4j problems

2003-11-13 Thread donald larmee|ALTERthought
I believe the problem is with syntax of your SQL statement, not w/ log4j per se 
try putting commas between your VALUES in your SQL statement.

-Don

On Thu, 13 Nov 2003 09:55:45 -0500 [EMAIL PROTECTED] wrote:
> 
> Howdy,
> Can you rerun your system with -Dlog4j.debug=true as a java runtime
> option, and tell us what you're logging in the logger.error(???) state
> ment?
> 
> Yoav Shapira
> Millennium ChemInformatics
> 
> 
> >-Original Message-
> >From: Magnus Andersson [mailto:[EMAIL PROTECTED]
> >Sent: Thursday, November 13, 2003 9:55 AM
> >To: Log4J Users List
> >Subject: ms sql server and log4j problems
> >
> >i got a problem with my database and log4j. I found a correct driver
> that
> >connect to database but i got a error
> >message that says:
> >log4j:ERROR Failed to excute sql
> >java.sql.SQLException: [MAGNUS]Line 1: Incorrect syntax near 'ERROR'.
> 
> >  at com.inet.tds.a.a(Unknown Source)
> >  at com.inet.tds.g.if(Unknown Source)
> >  at com.inet.tds.g.executeUpdate(Unknown Source)
> >  at
> >org.apache.log4j.jdbc.JDBCAppender.execute(JDBCAppender.java:163)
> >  at
> >org.apache.log4j.jdbc.JDBCAppender.flushBuffer(JDBCAppender.java:235)
> 
> >
> >  at org.apache.log4j.jdbc.JDBCAppender.append(JDBCAppender.jav
> a:131)
> >  at
> >org.apache.log4j.AppenderSkeleton.doAppend(AppenderSkeleton.java:221)
> 
> >
> >  at
> >org.apache.log4j.helpers.AppenderAttachableImpl.appendLoopOnAppenders
> 
> >(AppenderAttachableImpl.java:57)
> >  at org.apache.log4j.Category.callAppenders(Category.java:187)
> 
> >  at org.apache.log4j.Category.forcedLog(Category.java:372)
> >  at org.apache.log4j.Category.error(Category.java:286)
> >  at GetMail.main(GetMail.java:76)
> >and that 'ERROR' is in the java code the first log message it says
> >logger.error("logging started");
> >
> >This is the config file:
> >log4j.rootLogger=DEBUG, ROOT
> >
> >
> >#log4j.appender.ROOT.Driver=sun.jdbc.odbc.JdbcOdbcDriver
> >
> >log4j.appender.ROOT=org.apache.log4j.jdbc.JDBCAppender
> >log4j.appender.ROOT.Driver=com.inet.tds.TdsDriver
> >
> >log4j.appender.ROOT.URL=jdbc:inetdae7:MAGNUS:1433?database=Log4j_
> db
> >log4j.appender.ROOT.user=sa
> >log4j.appender.ROOT.password=sa
> >log4j.appender.ROOT.sql=INSERT INTO JDBCTEST (Date, Priority, Logge
> r,
> >Method, Message) VALUES ('%d{-
> >MMM-dd HH:mm:ss,SSS}' '%-5.5p' '%C'  '%M' '%m\r\n')
> >log4j.appender.ROOT.layout=org.apache.log4j.PatternLayout
> >PLEASE what is wrong???
> >
> >
> >  Vad står det om dig på nätet? - http://www.lycos.se/
> >
> 
> 
> 
> 
> This e-mail, including any attachments, is a confidential business com
> munication, and may contain information that is confidential, propriet
> ary and/or privileged.This e-mail is intended only for the individua
> l(s) to whom it is addressed, and may not be saved, copied, printed, d
> isclosed or used by anyone else.  If you are not the(an) intended reci
> pient, please immediately delete this e-mail from your computer system
>  and notify the sender.  Thank you.
> 
> 
> -
> 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: Mapped Diagnostic Context in Struts Action Class

2003-10-22 Thread Donald Larmee | ALTERthought
I have done what you are attempting with no unexpected results... i.e., 
UserA maps to address 1 and UserB maps to address 2 just fine.

The ability for this to work correctly really lies more with the Thread 
strategy employed by your servlet engine, and less on Struts in order 
for this to work as designed you need to make sure that your Servlet engine 
is configured to use a multi-threading model (which is the out of the box 
default for most...)

At 04:32 AM 10/22/2003, Yu Xiang Xi  (Maveo) wrote:
Hi, this is a combination question about both log4j and struts.

For the MDC is managed on a per thread basis, we can use it to log the user
IP address in the web application.
While, as I remember, struts action class is designed to be thread-safe.
If I try to log the user IP address in the execute () method of struts
action class,
For example
public ActionForward execute(ActionMapping actionMapping, ActionForm
actionForm,  HttpServletRequest request, HttpServletResponse response)
throws Exception {
   String username=session.getAttribute("user");
MDC.put("userip",request.getRemoteAddr());
logger.info(username+" login");
..
}
Will the unexpected case happen?

1. UserA from 192.168.0.1 login, and the MDC put 192.168.0.1 to the MDC
2. UserB from 192.168.0.2 login, and the MDC put 192.168.0.2 to the MDC(now
the userip in MDC  is updated)
3. UserA executed the code logger.info(username+" login");
4. UserA executed the code logger.info(username+" login");
so the log4j output maybe look like
[192.168.0.2] UserA login
[192.168.0.2] UserB login
Actually the assumption is
[192.168.0.1] UserA login
[192.168.0.2] UserB login
Best Regards
Xi Yuxiang
System Architect
Maveo Systems Limited - www.maveosystems.com
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


___

  Donald H. Larmee
  ALTERthought, Inc.
  804.301.8867 (c)
  www.alterthought.com
___ 

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


RE: logging JDBC objects

2003-09-04 Thread Donald Larmee | ALTERTHOUGHT
Re: Public info
You are correct, although one can attempt to cheat a bit and get access to 
private material by calling the AccessibleObject.setAccessible() method to 
force an override. (will work unless the JVM has had its SecurityManager 
permissions tightened up a bit :) )

-don

At 11:51 AM 9/4/2003 -0400, Shapira, Yoav wrote:


Howdy,
Another take on this is BeanUtils#describe(Object bean) which returns a
Map of properties.  Java.util.HashMap's toString() method prints out
very nicely, so you don't have to do much work here.  (I'm talking about
jakarta-commons-beanutils of course ;))
A downside to both the above and I assume Senior Larmee's approach is
that they only invoke public methods, so you don't get private state in
your logging output.
Yoav Shapira
Millennium ChemInformatics
>-Original Message-
>From: Donald Larmee | ALTERTHOUGHT [mailto:[EMAIL PROTECTED]
>Sent: Thursday, September 04, 2003 10:02 AM
>To: Log4J Users List
>Subject: RE: logging JDBC objects
>
>In the past I have used a generic bean-util style widget that uses
>reflection to introspect any passed Object, and dumps its contents into
a
>formatted Stringwhich is then in turn logged.
>
>The DumpUtil (as I have implemented anyway) works well for reasonably
>simple/flat Objects, but does not have the smarts to generically
>traverse  into Collections/arrays.  If interested I can post/email.
>
>-don
>
>
>At 08:47 AM 9/4/2003 -0400, Shapira, Yoav wrote:
>
>
>>Howdy,
>>I personally am not a big fan of logging these types of objects: I
much
>>prefer logging the beans I create from result sets (or DAO objects, or
>>whatever we call them this week).  However, one possibility for you
>>would be to create a ResultSetRenderer (implements
>>http://jakarta.apache.org/log4j/docs/api/org/apache/log4j/or/ObjectRen
de
>>rer.html)
>>or a PreparedStatementRenderer...
>>
>>Yoav Shapira
>>Millennium ChemInformatics
>>
>>
>> >-Original Message-
>> >From: Larry Young [mailto:[EMAIL PROTECTED]
>> >Sent: Wednesday, September 03, 2003 8:30 PM
>> >To: [EMAIL PROTECTED]
>> >Subject: logging JDBC objects
>> >
>> >Hello,
>> >
>> > Has anyone looked at logging JDBC objects, like
>>PreparedStatement
>> >and ResultSet classes?  They don't have any built-in ways of
displaying
>> >their contents, so I'm considering creating a wrapper class to do
this
>>for
>> >me, but I thought I'd check the list to see if anyone else has
already
>> >solved this problem before I proceed.
>> >
>> >--- regards ---
>> >Larry
>> >
>> >
>> >--
>> >Larry Young
>> >The Dalmatian Group
>> >www.dalmatian.com
>> >
>> >
>> >
>>
>-
>> >To unsubscribe, e-mail: [EMAIL PROTECTED]
>> >For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>>
>>
>>This e-mail, including any attachments, is a confidential business
>>communication, and may contain information that is confidential,
>>proprietary and/or privileged.  This e-mail is intended only for the
>>individual(s) to whom it is addressed, and may not be saved, copied,
>>printed, disclosed or used by anyone else.  If you are not the(an)
>>intended recipient, please immediately delete this e-mail from your
>>computer system and notify the sender.  Thank you.
>>
>>
>>-
>>To unsubscribe, e-mail: [EMAIL PROTECTED]
>>For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>___
>
>   Donald H. Larmee
>   ALTERthought, Inc.
>   804.301.8867 (c)
>
>   www.alterthought.com
>___
>
>
>
>-
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]


This e-mail, including any attachments, is a confidential business 
communication, and may contain information that is confidential, 
proprietary and/or privileged.  This e-mail is intended only for the 
individual(s) to whom it is addressed, and may not be saved, copied, 
printed, disclosed or used by anyone else.  If you are not the(an) 
intended recipient, please immediately delete this e-mail from your 
computer system and notify the sender.  Thank you.

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


___

  Donald H. Larmee
  ALTERthought, Inc.
  804.301.8867 (c)
  www.alterthought.com
___


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


RE: logging JDBC objects

2003-09-04 Thread Donald Larmee | ALTERTHOUGHT
In the past I have used a generic bean-util style widget that uses 
reflection to introspect any passed Object, and dumps its contents into a 
formatted Stringwhich is then in turn logged.

The DumpUtil (as I have implemented anyway) works well for reasonably 
simple/flat Objects, but does not have the smarts to generically 
traverse  into Collections/arrays.  If interested I can post/email.

-don

At 08:47 AM 9/4/2003 -0400, Shapira, Yoav wrote:


Howdy,
I personally am not a big fan of logging these types of objects: I much
prefer logging the beans I create from result sets (or DAO objects, or
whatever we call them this week).  However, one possibility for you
would be to create a ResultSetRenderer (implements
http://jakarta.apache.org/log4j/docs/api/org/apache/log4j/or/ObjectRende
rer.html)
or a PreparedStatementRenderer...
Yoav Shapira
Millennium ChemInformatics
>-Original Message-
>From: Larry Young [mailto:[EMAIL PROTECTED]
>Sent: Wednesday, September 03, 2003 8:30 PM
>To: [EMAIL PROTECTED]
>Subject: logging JDBC objects
>
>Hello,
>
> Has anyone looked at logging JDBC objects, like
PreparedStatement
>and ResultSet classes?  They don't have any built-in ways of displaying
>their contents, so I'm considering creating a wrapper class to do this
for
>me, but I thought I'd check the list to see if anyone else has already
>solved this problem before I proceed.
>
>--- regards ---
>Larry
>
>
>--
>Larry Young
>The Dalmatian Group
>www.dalmatian.com
>
>
>
>-
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]


This e-mail, including any attachments, is a confidential business 
communication, and may contain information that is confidential, 
proprietary and/or privileged.  This e-mail is intended only for the 
individual(s) to whom it is addressed, and may not be saved, copied, 
printed, disclosed or used by anyone else.  If you are not the(an) 
intended recipient, please immediately delete this e-mail from your 
computer system and notify the sender.  Thank you.

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


___

  Donald H. Larmee
  ALTERthought, Inc.
  804.301.8867 (c)
  www.alterthought.com
___


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


RE: Log file location

2003-08-29 Thread Donald Larmee | ALTERTHOUGHT
Re: Bug in jBoss

Alas. Actually/unfortunately the 2.3 (and 2.4 proposed final draft) Servlet 
spec only 'suggests' that the Containers ClassLoader give preference to the 
WebApp (http://www.jcp.org/aboutJava/communityprocess/final/jsr053/):

  "SRV.9.7.2 Web Application Classloader

  ...It is recommended also that the application class loader be 
implemented so
  that classes and resources packaged within the WAR are loaded in 
preference to
  classes and resources residing in container-wide library JARs."

Note the use of the word 'recommended' and not 'required'

 FWIW, I have always ended up punting on this one and placing my log4j 
configuration into the jBoss server's log4j.xml file.  Perhaps jBoss 4.X 
has addressed this (I have not used it yet)?



At 02:05 AM 8/28/2003 -0500, Jacob Kjome wrote:


Well, if you your app is seeing jboss/lib/log4j.jar in preference to 
WEB-INF/lib/log4j.jar, then there is a bug in JBoss.  The Servlet spec 
states that (contrary to the normal Java2 classloading scheme) classes and 
libraries in WEB-INF/classes and WEB-INF/lib are checked first for 
classloading and if the classes are not found there, only then does it 
look to a higher classloader to attempt to load the classes.

I know JBoss has some concept of a single classloader across the whole 
server (I think that is what I read), but if it doesn't allow for a 
separate WebappClassLoader, then I think it is a spec compliance 
violation.  What does the JBoss group have to say about this?  Putting 
log4j.jar in WEB-INF/lib *should* provide a completely separate logging 
environment from the one JBoss uses.

Jake

At 12:09 PM 8/28/2003 +0530, you wrote:
Hi Jake,

Thanks for the information. I have gone through the stuff you've written.

Here's what I'm doing:
1. I placed log4j-1.2.8.jar in WEB-INF/lib
2. I placed log4j.properties in WEB-INF/classes
3. I deployed the application on JBoss 3.2.1
By default, JBoss has log4j.jar in jboss/lib which is in my classpath.
So, even my application class loader takes the classes from log4j.jar 
located in jboss/lib?

If I remove log4j.jar in jboss/lib, then I think I will not get server 
log of JBoss.

How to solve this issue? Please inform.

Sriram

-Original Message-
From: Jacob Kjome [mailto:[EMAIL PROTECTED]
Sent: Thursday, August 28, 2003 11:00 AM
To: Log4J Users List
Subject: RE: Log file location


Hi Sriram,

Do you have log4j.jar in WEB-INF/lib?  If not, I'd expect default
initialization not to work.  Remember that the webapp class loader can see
parent class loaders, but the parents cannot see the webapp class loader,
hence your log4j.properties will definitely not be found.  If you are
trying to use log4j.jar in a parent class loader and want your own
configuration file to be used in your own logging space, then you will need
to use a repository selector.  See the log4j-sandbox for working
examples.  I wrote something up about this stuff here... 
http://nagoya.apache.org/wiki/apachewiki.cgi?Log4JProjectPages/AppContainerLogging

Jake

At 09:35 AM 8/28/2003 +0530, you wrote:
>The properties file is not being read at all
>
>I placed it in WEB-INF/classes.
>
>Still it's not being read.
>
>I am JBoss and JBoss contains log4j.jar by default and it has log4j.xml
>in
>default/conf folder.
>Probably even my application is taking log4j.xml from that location by
>default. I need to check that. Anyone who has implemented log4j for their
>applications on JBoss, pl. suggest.
>
>
>Sriram
>
>-Original Message-
>From: Ceki Gülcü [mailto:[EMAIL PROTECTED]
>Sent: Wednesday, August 27, 2003 6:52 PM
>To: Log4J Users List
>Subject: Re: Log file location
>
>
>
>Is the properties file being read at all?
>
>At 06:25 PM 8/27/2003 +0530, sriram wrote:
> >Hi,
> >
> >I am unable to set log file location. I searched the forum for old
> >messages and found some. I tried the way it was mentioned in those
> >messages, but still my problem is not solved.
> >
> >My log4j.properties file is as follows:
> >
> >log4j.rootCategory=WARN, dest1, R
> >log4j.appender.dest1=org.apache.log4j.ConsoleAppender
> >log4j.appender.dest1.layout=org.apache.log4j.PatternLayout
> >log4j.appender.dest1.layout.ConversionPattern=%-5p: %m%n
> >
> > appender writes to a file
> >log4j.appender.R=org.apache.log4j.RollingFileAppender
> >log4j.appender.R.layout=org.apache.log4j.PatternLayout
> >log4j.appender.R.layout.ConversionPattern=%-5p: %m%n
> >log4j.appender.R.File=d:/jboss/errors.log
> >
> >
> >I packaged  by application as .ear and deployed it on JBoss running
> >on Win 2000.
> >
> >When I run the application, I can see the log messages on JBoss
> >console, but these messages are not getting stored in the file I've
> >specified (d:/jboss/errors.log).
> >
> >What could be the problem? In fact, initially I tried
> >${jboss.home}/errors.log, but it didn't work. So I thought of hard
> >coding the file location and tried it out. Still the same problem.
> >
> >Can someone please suggest a solut