You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Davide Marche <ja...@email.it> on 2006/02/07 09:46:18 UTC

iBATIS and log4j

Hi everybody,

i am trying to use iBATIS (with DAO) in my web application, but i have a
problem when I try to use log4j. In a standalone application i don't
have any problem with log4j, but in this web application i cannot find a
way for iBATIS to use log4j and to use log4j in the other parts of my
web application.
In other words, i created the file log4j.properties and put it into the
default package (which is WEB-INF/classes when you deploy the
application), and i am sure the file itself is correct (it perfectly
works if i load it in a servlet). Just it seems iBATIS cannot find it.
Then i tryed to write an InitServlet that id loaded at the startup
(with<load-on-startup>1</load-on-startup>). It works from the log4j
point of view, because i am actually able to use it from my servlets,
but iBATIS still doesn't see it and doesn't log anything.
If it can help i also noticed that sometimes when the application starts
using the iBATIS DAO objects i receive this message

finalized appender named [name_of_the_appender]

and it actually stops logging at all. In few words, it seems like a
conflict.
My question is: is there anybody who managed to use iBATIS (and log4j)
in a web application AND use log4j in the business and application logic?
I tryed to look for informations about how iBATIS initialize log4j but i
couldn't find anything.

Any help or hint would be appreciated

Thanks in advance,
Davide Marche


Re: iBATIS and log4j

Posted by Davide Marche <ja...@email.it>.
Thank you Guido,

I am currently using ibatis 2.1.5 and tomcat 5.0.28, do you think it's
possible there is the same problem with tomcat 5?

I really would like to understand how it works for you. Do you have any
special initialization of log4j in your webapp? Or do your DAO objects
simply log to the console correctly ?

Thanks in advance


> I had the same problem when using ibatis 2.0.9 + tomcat 4.1.x (I think
> there is a conflict with the commons-logging.jar).
> It works fine for me with other servers (Sun ONE)...
>
> iBatis 2.1.5 removed commons-logging dependency, maybe you are using
> an older version...
>
> http://mail-archives.apache.org/mod_mbox/ibatis-user-java/200504.mbox/%3C91ll51tfp5s49s57v7or4k5gbgea2fpqkm@4ax.com%3E
>
>
> Good look,
> Guido García Bernardo.
>
> PD: This is my WEB-INF/classes/log4j.properties:
>
>    log4j.appender.stdout=org.apache.log4j.ConsoleAppender
>    log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
>    log4j.appender.stdout.layout.ConversionPattern=%3p %d{ABSOLUTE} [%t
> %c{1}] - %m%n
>
>    log4j.logger.com.ibatis=DEBUG, stdout
>    log4j.logger.com.ibatis.common.jdbc.SimpleDataSource=DEBUG, stdout
>    log4j.logger.java.sql.Connection=DEBUG, stdout
>    log4j.logger.java.sql.Statement=DEBUG, stdout
>    log4j.logger.java.sql.PreparedStatement=DEBUG, stdout
>    log4j.logger.java.sql.ResultSet=DEBUG, stdout
>
>



Re: iBATIS and log4j

Posted by Guido García Bernardo <gg...@tid.es>.
I had the same problem when using ibatis 2.0.9 + tomcat 4.1.x (I think 
there is a conflict with the commons-logging.jar).
It works fine for me with other servers (Sun ONE)...

iBatis 2.1.5 removed commons-logging dependency, maybe you are using an 
older version...

http://mail-archives.apache.org/mod_mbox/ibatis-user-java/200504.mbox/%3C91ll51tfp5s49s57v7or4k5gbgea2fpqkm@4ax.com%3E

Good look,
Guido García Bernardo.

PD: This is my WEB-INF/classes/log4j.properties:

    log4j.appender.stdout=org.apache.log4j.ConsoleAppender
    log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
    log4j.appender.stdout.layout.ConversionPattern=%3p %d{ABSOLUTE} [%t 
%c{1}] - %m%n

    log4j.logger.com.ibatis=DEBUG, stdout
    log4j.logger.com.ibatis.common.jdbc.SimpleDataSource=DEBUG, stdout
    log4j.logger.java.sql.Connection=DEBUG, stdout
    log4j.logger.java.sql.Statement=DEBUG, stdout
    log4j.logger.java.sql.PreparedStatement=DEBUG, stdout
    log4j.logger.java.sql.ResultSet=DEBUG, stdout


Davide Marche escribió:
> Hi everybody,
>
> i am trying to use iBATIS (with DAO) in my web application, but i have a
> problem when I try to use log4j. In a standalone application i don't
> have any problem with log4j, but in this web application i cannot find a
> way for iBATIS to use log4j and to use log4j in the other parts of my
> web application.
> In other words, i created the file log4j.properties and put it into the
> default package (which is WEB-INF/classes when you deploy the
> application), and i am sure the file itself is correct (it perfectly
> works if i load it in a servlet). Just it seems iBATIS cannot find it.
> Then i tryed to write an InitServlet that id loaded at the startup
> (with<load-on-startup>1</load-on-startup>). It works from the log4j
> point of view, because i am actually able to use it from my servlets,
> but iBATIS still doesn't see it and doesn't log anything.
> If it can help i also noticed that sometimes when the application starts
> using the iBATIS DAO objects i receive this message
>
> finalized appender named [name_of_the_appender]
>
> and it actually stops logging at all. In few words, it seems like a
> conflict.
> My question is: is there anybody who managed to use iBATIS (and log4j)
> in a web application AND use log4j in the business and application logic?
> I tryed to look for informations about how iBATIS initialize log4j but i
> couldn't find anything.
>
> Any help or hint would be appreciated
>
> Thanks in advance,
> Davide Marche
>
>
>   


-- 
Guido García Bernardo
have a nice wifree !

Tfn. +34 983 54 89 08
ITDEUSTO - Valladolid