Avatar billede fredand Forsker
16. juni 2006 - 14:24 Der er 3 kommentarer og
1 løsning

How to use Log4j from EJB in WebLogic?

Hello!

I have a ejb-app that is deployed in a weblogic 8.13 like a exploded folder and not from a .ear-file (I do not think that matters)

My problem is that when I try to use Log4j I get nothing at all appended to the console. System.out.println works.

Since the code executes with out any problem I guess there must be some error with the log4j.properties. It looks like:

# Set root logger level to DEBUG and its only appender to A1.
log4j.rootLogger=DEBUG, A1

# A1 is set to be a ConsoleAppender.
log4j.appender.A1=org.apache.log4j.ConsoleAppender

# A1 uses PatternLayout.
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n

My exploded app looks like:
D:/EJBHOME/com/MyMDB.class
D:/EJBHOME/log4j.properties

I have also put the file log4j.properties the folder System.getProperty("user.dir")

But nothing gets printed to the console. Do you see the error?

My code looks like:
...
import org.apache.log4j.Logger;

public class ManagerMDB implements MessageDrivenBean, MessageListener
{


    private static final Logger logger = Logger.getLogger(ManagerMDB.class);

    public void onMessage(Message message)
    {
      logger.debug("Hello");
...
...

Best regards
Fredrik
Avatar billede arne_v Ekspert
16. juni 2006 - 15:52 #1
log4j.appender.A1.threshold = debug

maaske ?
Avatar billede fredand Forsker
16. juni 2006 - 22:06 #2
Hello!

Thanks for your reply!

I never manage to set the log4j.properties correct or the MDB never found the file.

How ever I found this page:
http://logging.apache.org/log4j/docs/manual.html

and added some code like:
BasicConfigurator.configure();
logger.setLevel(Level.DEBUG);

Not the idea with log4j and not beutiful but it works for me!

Best regards

BTW give a svar so I may reward for your valuable time mate! I is worth alot to me!
Avatar billede arne_v Ekspert
18. juni 2006 - 03:01 #3
no thanks (in this one)

I belive that log4j looks for log4j.properties in classpath !
Avatar billede fredand Forsker
30. december 2006 - 13:32 #4
Lets close this one
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester