commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Igor Smirnov" <i...@prozone.co.yu>
Subject Re: [logging] How to get logging to use new Monolog subclass
Date Wed, 12 May 2004 13:20:39 GMT
First of all, I have to admin I'd been stupid! :)
there is a commons-logging-api in bin folder, that isn't only the api but
the whole implementation. When I removed it I finally could start doing
actual tests...

Now, I came up with an excepntion. I happens in getLogConstructor method od
the LogFactoryImpl
logMethod stays null, and logConstructor stays null, therefore
LogConfigurationException!
The code
try {
logMethod = logClass.getMethod("setLogFactory",
logMethodSignature);
} catch (Throwable t) {
logMethod = null;}
// Identify the corresponding constructor to be used
try {
logConstructor = logClass.getConstructor(logConstructorSignature);
return (logConstructor);
} catch (Throwable t) {
throw new LogConfigurationException
("No suitable Log constructor " + logConstructorSignature+ " for " +
logClassName, t);}

Igor

----- Original Message -----
From: "José Antonio Pérez Testa" <japtesta@indra.es>
To: "Jakarta Commons Users List" <commons-user@jakarta.apache.org>
Sent: Wednesday, May 12, 2004 1:20 PM
Subject: Re: [logging] How to get logging to use new Monolog subclass


> Reached this point, I would write System.out.println() statements after
> every line of the metod
> getLogClassName() of
>
> LogFactoryImpl.java
>
> and try to find out what is happenning ....
>
> Igor Smirnov wrote:
>
> >As previously said, I had implemented this method. It seams like I am not
> >getting any exceptions. I start the Tomcat up, it reads trough the
> >common-logging.properties, where it should initialize my logger.
> >I checked both my class and the logs for exceptions and haven't found
any.
> >
> >----- Original Message -----
> >From: "José Antonio Pérez Testa" <japtesta@indra.es>
> >To: "Jakarta Commons Users List" <commons-user@jakarta.apache.org>
> >Sent: Wednesday, May 12, 2004 11:45 AM
> >Subject: Re: [logging] How to get logging to use new Monolog subclass
> >
> >
> >
> >
> >>Can you add the code for 'isMonologAvailable()' ?
> >>
> >>it should look like log4j's:
> >>    protected boolean isLog4JAvailable() {
> >>
> >>        try {
> >>            loadClass("org.apache.log4j.Logger");
> >>            loadClass("org.apache.commons.logging.impl.Log4JLogger");
> >>            return (true);
> >>        } catch (Throwable t) {
> >>            return (false);
> >>        }
> >>    }
> >>so if you can load the implementation you can use it!
> >>
> >>In any case, you must be catching some kind of exception in some place,
> >>could you give the exception printStackTrace() ???
> >>
> >>Igor Smirnov wrote:
> >>
> >>
> >>
> >>>I've been trying to make it run, but I keep getting log4j instead. I
have
> >>>added to LogFactoryImpl.java.
> >>>
> >>>if ((logClassName == null) && isMonologAvailable()) {
> >>>           logClassName =
> >>>
> >>>
> >"org.apache.commons.logging.impl.MonologLogger";
> >
> >
> >>>       }
> >>>and isMonologAvailable() which returns true.
> >>>
> >>>Any ideas why it will not work? It seams like it falls back to log4j
> >>>
> >>>
> >(if?)
> >
> >
> >>>it doesn't find Monologs class.(?)
> >>>
> >>>Thanks,
> >>>Igor
> >>>
> >>>----- Original Message -----
> >>>From: "José Antonio Pérez Testa" <japtesta@indra.es>
> >>>To: "Jakarta Commons Users List" <commons-user@jakarta.apache.org>
> >>>Sent: Tuesday, May 11, 2004 12:16 PM
> >>>Subject: Re: [logging] How to get logging to use new Monolog subclass
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>>Well, now try this
> >>>>WEB_INF/classes/commons-logging.properties
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>
>
>>org.apache.commons.logging.LogFactory=org.apache.commons.logging.impl.LogF
a
> >>
> >>
> >c
> >
> >
> >>>toryImpl
> >>>
> >>>
> >>>
> >>>
>
>>org.apache.commons.logging.Log=org.apache.commons.logging.impl.MonologLogg
e
> >>
> >>
> >r
> >
> >
> >>>
> >>>
> >>>>Igor Smirnov wrote:
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>>Following instructions, I made Commons Logging use log4j in Tomcat.
> >>>>>Now, everything runs smoothly, but - I still need to configure
Commons
> >>>>>Logging to use my new logger implementation:
> >>>>>org.apache.commons.logging.impl.MonologLogger
> >>>>>It is the implementation for Monolog (objectwebs project).
> >>>>>How does commong logging recognize custom loggers? Monolog uses it's
> >>>>>monolog.properties file to set up the logging events.
> >>>>>
> >>>>>Thank you
> >>>>>
> >>>>>----- Original Message -----
> >>>>>From: "José Antonio Pérez Testa" <japtesta@indra.es>
> >>>>>To: "Jakarta Commons Users List" <commons-user@jakarta.apache.org>
> >>>>>Sent: Monday, May 10, 2004 11:12 AM
> >>>>>Subject: Re: [logging] How to get logging to use new Monolog subclass
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>>By default Commons Logging uses Log4j implementation, if the
libraries
> >>>>>>are available on the classpath you should be able to log to a
Log4j
> >>>>>>implementation without no configuration (apart from log4j.properties
> >>>>>>
> >>>>>>
> >or
> >
> >
> >>>>>>equivalent xml file).
> >>>>>>I am writing logs to log4j with Commons Logging in many projects
and
> >>>>>>
> >>>>>>
> >the
> >
> >
> >>>>>>only difficults I've found  were with AppServer precedence of
> >>>>>>
> >>>>>>
> >libraries.
> >
> >
> >>>>>>You should try to configure log4j implementation first, and when
this
> >>>>>>implementation works give a try with Monolog
> >>>>>>
> >>>>>>
> >>>>>>Simon Kitching wrote:
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>>On Mon, 2004-05-10 at 20:22, Igor Smirnov wrote:
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>>Hollowing Simon's suggestion, I am posting the same question
under
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>another
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>>>>Subject.
> >>>>>>>>
> >>>>>>>>And to be more specific: I am working tiwht Monolog logger
that
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>implements
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>>>>and extends log4j functionality. I needed a new Log impl.
in
commons
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>logging
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>>>>to be able to use Monolog logger with tomcat.
> >>>>>>>>Hopefully this clears it up. And here's the first post:
> >>>>>>>>
> >>>>>>>>I've working with commons logging for the past week and
have
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>implemented
> >>>
> >>>
> >>>
> >>>
> >>>>>>>>
> >>>>>>>>
> >>>>>a
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>>>>new logger within for my needs.
> >>>>>>>>Now, since I am not confortable with the whole commons
package yet
> >>>>>>>>
> >>>>>>>>
> >and
> >
> >
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>the
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>>>>user's guide doesn't help much, could anyone explain
me step by
step
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>how
> >>>
> >>>
> >>>
> >>>
> >>>>>>>>
> >>>>>>>>
> >>>>>to
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>>>>set-up my system to use the new logger?
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>Cool, I'll have to look into monolog a bit.
> >>>>>>>
> >>>>>>>
> >>>>>>>As Jose mentioned, you can just set a system property on
the jvm
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>command
> >>>
> >>>
> >>>
> >>>
> >>>>>>>line:
> >>>>>>>java -Dorg.apache.commons.logging.Log=your.log.class
> >>>>>>>(described in the LogFactoryImpl javadoc)
> >>>>>>>
> >>>>>>>This is fine for debugging, but isn't very nice when building
> >>>>>>>frameworks, etc. But from a quick peek at the code, it looks
like
you
> >>>>>>>can also create a file "commons-logging.properties" and put
it in
the
> >>>>>>>classpath, with these contents:
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
>
>>>>org.apache.commons.logging.LogFactory=org.apache.commons.logging.impl.Lo
g
> >>>>
> >>>>
> >F
> >
> >
> >>>>>
> >>>>>
> >>>a
> >>>
> >>>
> >>>
> >>>
> >>>>>>
> >>>>>>
> >>>>>ctoryImpl
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>>>org.apache.commons.logging.Log=your.log.class
> >>>>>>>
> >>>>>>>And as a third option, it looks like you could define your
own
> >>>>>>>LogFactory subclass, and then specify it by creating a file:
> >>>>>>>META-INF/services/org.apache.commons.logging.LogFactory
> >>>>>>>with its first line being:
> >>>>>>>your.logfactory.class
> >>>>>>>
> >>>>>>>
> >>>>>>>I've only used the -D approach myself, so the above might
be wrong.
> >>>>>>>
> >>>>>>>
> >As
> >
> >
> >>>>>>>always, the source code is the official and final documentation!
The
> >>>>>>>LogFactory and LogFactoryImpl classes are the ones that control
all
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>this
> >>>
> >>>
> >>>
> >>>
> >>>>>>>behaviour.
> >>>>>>>
> >>>>>>>Regards,
> >>>>>>>
> >>>>>>>Simon
> >>>>>>>
> >>>>>>>
>
>>>>>>>---------------------------------------------------------------------
> >>>>>>>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> >>>>>>>For additional commands, e-mail:
commons-user-help@jakarta.apache.org
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
>
>>>>------------------------------------------------------------------------
-
> >>>>
> >>>>
> >-
> >
> >
> >>>>>
> >>>>>
> >>>>>>
> >>>>>>
> >>>>>-----------------------------------------
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>>Este correo electrónico y, en su caso, cualquier fichero anexo
al
> >>>>>>
> >>>>>>
> >mismo,
> >
> >
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>contiene información de carácter confidencial exclusivamente dirigida
a
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>su
> >>>
> >>>
> >>>
> >>>
> >>>>>destinatario o destinatarios. Queda prohibida su divulgación, copia
o
> >>>>>distribución a terceros sin la previa autorización escrita de Indra.
En
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>el
> >>>
> >>>
> >>>
> >>>
> >>>>>caso de haber recibido este correo electrónico por error, se ruega
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>notificar
> >>>
> >>>
> >>>
> >>>
> >>>>>inmediatamente esta circunstancia mediante reenvío a la dirección
> >>>>>electrónica del remitente.
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>>The information in this e-mail and in any attachments is
confidential
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>
> >>>and
> >>>
> >>>
> >>>
> >>>
> >>>>>>
> >>>>>>
> >>>>>solely for the attention and use of the named addressee(s). You are
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>hereby
> >>>
> >>>
> >>>
> >>>
> >>>>>notified that any dissemination, distribution or copy of this
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>communication
> >>>
> >>>
> >>>
> >>>
> >>>>>is prohibited without the prior written consent of Indra. If you
have
> >>>>>received this communication in error, please, notify the sender by
> >>>>>
> >>>>>
> >reply
> >
> >
> >>>>>e-mail
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
>
>>>>>>---------------------------------------------------------------------
> >>>>>>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> >>>>>>For additional commands, e-mail:
commons-user-help@jakarta.apache.org
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>---------------------------------------------------------------------
> >>>>>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> >>>>>For additional commands, e-mail: commons-user-help@jakarta.apache.org
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
>
>>>-------------------------------------------------------------------------
-
> >>>
> >>>
> >>>>
> >>>>
> >>>-----------------------------------------
> >>>
> >>>
> >>>
> >>>
> >>>>Este correo electrónico y, en su caso, cualquier fichero anexo al
mismo,
> >>>>
> >>>>
> >>>>
> >>>>
> >>>contiene información de carácter confidencial exclusivamente dirigida a
> >>>
> >>>
> >su
> >
> >
> >>>destinatario o destinatarios. Queda prohibida su divulgación, copia o
> >>>distribución a terceros sin la previa autorización escrita de Indra. En
> >>>
> >>>
> >el
> >
> >
> >>>caso de haber recibido este correo electrónico por error, se ruega
> >>>
> >>>
> >notificar
> >
> >
> >>>inmediatamente esta circunstancia mediante reenvío a la dirección
> >>>electrónica del remitente.
> >>>
> >>>
> >>>
> >>>
> >>>>The information in this e-mail and in any attachments is confidential
> >>>>
> >>>>
> >and
> >
> >
> >>>>
> >>>>
> >>>solely for the attention and use of the named addressee(s). You are
> >>>
> >>>
> >hereby
> >
> >
> >>>notified that any dissemination, distribution or copy of this
> >>>
> >>>
> >communication
> >
> >
> >>>is prohibited without the prior written consent of Indra. If you have
> >>>received this communication in error, please, notify the sender by
reply
> >>>e-mail
> >>>
> >>>
> >>>
> >>>
> >>>>---------------------------------------------------------------------
> >>>>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> >>>>For additional commands, e-mail: commons-user-help@jakarta.apache.org
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>
> >>>---------------------------------------------------------------------
> >>>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> >>>For additional commands, e-mail: commons-user-help@jakarta.apache.org
> >>>
> >>>
> >>>
> >>>
> >>>
>
>>--------------------------------------------------------------------------
> >>
> >>
> >-----------------------------------------
> >
> >
> >>Este correo electrónico y, en su caso, cualquier fichero anexo al mismo,
> >>
> >>
> >contiene información de carácter confidencial exclusivamente dirigida a
su
> >destinatario o destinatarios. Queda prohibida su divulgación, copia o
> >distribución a terceros sin la previa autorización escrita de Indra. En
el
> >caso de haber recibido este correo electrónico por error, se ruega
notificar
> >inmediatamente esta circunstancia mediante reenvío a la dirección
> >electrónica del remitente.
> >
> >
> >>The information in this e-mail and in any attachments is confidential
and
> >>
> >>
> >solely for the attention and use of the named addressee(s). You are
hereby
> >notified that any dissemination, distribution or copy of this
communication
> >is prohibited without the prior written consent of Indra. If you have
> >received this communication in error, please, notify the sender by reply
> >e-mail
> >
> >
> >>---------------------------------------------------------------------
> >>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> >>For additional commands, e-mail: commons-user-help@jakarta.apache.org
> >>
> >>
> >>
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> >For additional commands, e-mail: commons-user-help@jakarta.apache.org
> >
> >
> >
>
> --------------------------------------------------------------------------
-----------------------------------------
> Este correo electrónico y, en su caso, cualquier fichero anexo al mismo,
contiene información de carácter confidencial exclusivamente dirigida a su
destinatario o destinatarios. Queda prohibida su divulgación, copia o
distribución a terceros sin la previa autorización escrita de Indra. En el
caso de haber recibido este correo electrónico por error, se ruega notificar
inmediatamente esta circunstancia mediante reenvío a la dirección
electrónica del remitente.
>
> The information in this e-mail and in any attachments is confidential and
solely for the attention and use of the named addressee(s). You are hereby
notified that any dissemination, distribution or copy of this communication
is prohibited without the prior written consent of Indra. If you have
received this communication in error, please, notify the sender by reply
e-mail
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message