Mateusz Nowakowski (JIRA)
Tue, 02 Feb 2010 11:10:21 -0800
[
http://issues.ops4j.org/browse/PAXLOGGING-72?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13309#action_13309
]
Mateusz Nowakowski commented on PAXLOGGING-72:
----------------------------------------------
My appender is org.apache.log4j.DailyRollingFileAppender with own layout and
own error handler. I configure this appender in Spring DM:
{code}
<bean id="myAppender" class="org.apache.log4j.DailyRollingFileAppender"
init-method="activateOptions">
<property name="name" value="SWSMainAppender"/>
<property name="append" value="true"/>
<property name="datePattern" value="'.'yyyy-MM-dd-HH"/>
<property name="file"
value="${karaf.base}/data/log/someLog.log"/>
<property name="threshold">
<util:constant
static-field="org.apache.log4j.Level.DEBUG"/>
</property>
<property name="layout">
<bean
class="com.xxxxx.log4j.layout.SophisticatedLayout">
<property name="conversionPattern" value="..."/>
</bean>
</property>
<property name="errorHandler">
<bean class="com......SomeErrorHandler"
init-method="activateOptions">
<property name="appender"
ref="myMainAppender"/><!-- must be this appender -->
<property name="backupAppender"
ref="someOtherAppender"/>
<property name="a" value="c"/>
<property name="b" value="d"/>
</bean>
</property>
</bean>
<bean id="myPaxAppender" class="com.......PaxLog4jAppenderWrapper">
<property name="log4jAppender" ref="myMainAppender"/>
</bean>
<osgi:service ref="myPaxAppender"
interface="org.ops4j.pax.logging.spi.PaxAppender">
<osgi:service-properties>
<entry>
<key>
<util:constant
static-field="org.ops4j.pax.logging.PaxLoggingService.APPENDER_NAME_PROPERTY"/>
</key>
<value>MyAppender</value>
</entry>
</osgi:service-properties>
</osgi:service>
{code}
and ${karaf.base}/etc/org.ops4j.pax.logging.cfg contains like:
{code
log4j.logger.com.myCompany=INFO, osgi:MyAppender
{code}
This solution needs additional log4j bundle in the application, but it works.
And answer for your comments:
>1. The Log4j packages in Pax Logging API are NOT original code and augmented
>to fit into the OSGi environment.
What kind of changes? Could you provide some link to the docs about them, or
point the classes which are changed?
>3. I strongly want to avoid DynamicImport, so it won't be possible to "just
>use" any class that implements Log4j Appender.
Me neither. But the appender would be provided via OSGI service as it is
PaxAppender implementation, so PAX doesn't have to DynamicImport?
>"it is impossible to use all log4j capabilities" --> Yes, and it is both by
>design and by necessity. Sorry.
Very strange especially PAX Logging configuration is based on log4j.
>Perhaps if you explain what you want your own Appender to do, we just create
>one for Pax Logging,
Provide all log4j appenders as PaxAppenders and export them that other bundles
can extend them.
>but no real passion to do it...
The whole OSGI is not easy as it is supposed to be.
> No implementations available for PaxAppender
> --------------------------------------------
>
> Key: PAXLOGGING-72
> URL: http://issues.ops4j.org/browse/PAXLOGGING-72
> Project: Pax Logging
> Issue Type: Improvement
> Components: Service
> Affects Versions: 1.4
> Environment: WinXp, Fuse 4.2 RC1
> Reporter: Mateusz Nowakowski
> Assignee: Niclas Hedhman
>
> Currently it is not possible to use own appender based on log4j using
> existing PaxLoggingConfigurator. It is really strange because
> PaxLoggingConfigurator is based on log4j appenders.
> There can be used only PaxAppender implementation, but none is available.
> There are two solutions to solve the problem. Both are bad.
> - create own appender based on log4j appender and attach it via Fragment-Host
> mechanism to Pax Logging Service bundle -- bad solution, because current
> PaxLoggingConfigurator do not support error handlers etc (I've already
> created PAXLOGGING-71 for it)
> - write PaxAppender implementation which aggregates any log4 appender - bad,
> because it requires an additional log4j bundle in the application (Pax
> Logging exports only two log4j packages without most of log4j code,
> especially without appenders), what is more it is a performance killer,
> because PaxAppender implementation wraps some appender based on log4
> appender, and PAX creates own wrapper to return log4j appender from
> PaxAppender...
> There are two complementary solution:
> - PAXLOGGING-71
> - PaxLoggingConfigurator or its AppenderTracker should track not only
> PaxAppender but original log4j Appender. What is more all log4j packages
> should be exported.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.ops4j.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
_______________________________________________
general mailing list
general@lists.ops4j.org
http://lists.ops4j.org/mailman/listinfo/general