Hi,
your logger object is probably null , proably because the
"this.getLogger" method is
not working properly. Are you extending the right classes ?
I however am just using the log4j framework in for example my
CancelCheckoutAction class:
import org.apache.log4j.Logger;
static Logger log = Logger.getLogger( CancelCheckoutAction.class);
then you can call log.debug("etc").
You have to add the something similar as the following extract to
WEB-INF/web.xml (this patch resulted from uncommenting inside Lenya's
web-xml.xsl the similare code, but you can do it manually ):
<!--Patched by Lenya build process-->
<init-param>
<param-name>logger-class</param-name>
<param-value>org.apache.avalon.excalibur.logger.Log4JLoggerManager</param-value>
</init-param>
<init-param>
<param-name>log4j-config</param-name>
<param-value>/WEB-INF/log4j.xconf</param-value>
</init-param>
And then define your logging using /WEB-INF/log4j.xconf. I added a
appender and logger
for my "com.company.custom" package:
<appender name="CUSTOM_COMPANY" class="org.apache.log4j.FileAppender">
<param name="File" value="${context-root}/WEB-INF/logs/company.log" />
<param name="Append" value="false" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %-5p %c.%M():%L
%x - %m%n"/>
<!-- NOTE: Showing the method might slow down logging. In
order to improve performance use the pattern below -->
<!--<param name="ConversionPattern" value="%-4r %d [%t]
%-5p %c %x - %m%n"/>-->
</layout>
</appender>
<category name="com.company.custom" additivity="false">
<priority value="debug"/>
<appender-ref ref="CUSTOM_COMPANY" />
</category>
On 19/10/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
Hi folks,
guess I have another kind of low level question in terms of difficulties to
answer...
Some time ago I wrote my own transformer (special thanks to all who helped me!). This
transformer, in my case, extends the AbstractDOMTransformer class. Further, it imports
org.apache.avalon.framework.logger.Logger. This enables to call the following within the
transformer method: Logger logger = this.getLogger(); Moreover, its easy to output logger
messages via e.g. logger.info("text"); at logger level: info.
I am facing the following problem now: I wrote other classes who's methods
become called within my transformer. But how can I output logger messages
within these classes?
I already tried to import org.apache.avalon.framework.logger.Logger; and
org.apache.avalon.framework.logger.AbstractLogEnabled; Then I extended AbstractLogEnabled and tried
to get a transformer within my method by the following: Logger logger = this.getLogger(); (same way
as I did in my custome transformer). All this works fine in terms of compilation and runtime, but
when adding to output something via logger.info("msg") / logger.error("msg") /
... I run into a java.lang.RuntimeException: and java.lang.NullPointerException during runtime. At
the end, I tried to implement the LogEnabled interface as done here:
http://mail-archives.apache.org/mod_mbox/cocoon-users/200607.mbox/[EMAIL PROTECTED] - but it
doesn't work too (same exceptions).
Can someone tell me what I am doing wrong, or what I am missing?
thanks a lot for your help!
best regards
Thomas
btw: Lenya uses cocoon-2.1.7 - if someone would like to take a look at the
stacktrace, just let me know plz
--
Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!
Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer
---------------------------------------------------------------------
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]