additional logger for plugin in Nexus 2.x?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

additional logger for plugin in Nexus 2.x?

Max Spring
I'm struggling with Nexus' Slf4j / Logback.

I want my plugin to have it's own logger, completely independent from the main logger
while re-using Nexus' Logback library, i.e. without having to bundle another logging library.

And I don't want to have to manipulate any "global" logging config file -- everything should come with the plugin.

I'm following the "Invoking JoranConfigurator directly" example from
http://logback.qos.ch/manual/joran.html
to load my plugin's own logback.xml.

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
   <appender name="FILE" class="ch.qos.logback.core.FileAppender">
     <file>${nexus.log-config-dir}/../logs/access.log</file>
     <encoder>
       <pattern>%4d{yyyyMMdd-HHmmss} %m%n</pattern>
     </encoder>
   </appender>

   <logger name="accessLogger" level="INFO" additivity="false">
     <appender-ref ref="FILE"/>
   </logger>

   <root level="${nexus.log.level:-INFO}">
     <appender-ref ref="FILE"/>
   </root>
</configuration>

It doesn't work.  My log entries still show up in the regular nexus.log.
Or to be precise, only the first entries show up in the new log, but then magically subsequent entries go again into nexus.log.
Only if I re-create the logger using Joran, it kinda works.

Maybe this is all more of a Logback question?

-Max

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: additional logger for plugin in Nexus 2.x?

Tamás Cservenák
Max,

That happens as nexus "reconfigures" the logging in case of some events or such.

Take a peek at LogConfigurationParticipant, I believe what you want is
a component implementing this iface...

Examples of implementation:
https://github.com/sonatype/nexus/blob/master/nexus/nexus-logging-extras/src/main/java/org/sonatype/nexus/log/internal/LogbackNexusEventSystemLogConfigurationParticipant.java

Just create a component like this in your plugin, and you should be
able to "contribute" config to Nexus logging and achieve what you want
(ultimately, log into separate file if I get you right).

One thing: you would still need to use slf4japi + logback backend, but
I believe it should not bother you....


Thanks,
~t~


On Wed, May 9, 2012 at 11:59 PM, Max Spring <[hidden email]> wrote:

> I'm struggling with Nexus' Slf4j / Logback.
>
> I want my plugin to have it's own logger, completely independent from the
> main logger
> while re-using Nexus' Logback library, i.e. without having to bundle another
> logging library.
>
> And I don't want to have to manipulate any "global" logging config file --
> everything should come with the plugin.
>
> I'm following the "Invoking JoranConfigurator directly" example from
> http://logback.qos.ch/manual/joran.html
> to load my plugin's own logback.xml.
>
> <?xml version="1.0" encoding="UTF-8"?>
> <configuration>
>  <appender name="FILE" class="ch.qos.logback.core.FileAppender">
>    <file>${nexus.log-config-dir}/../logs/access.log</file>
>    <encoder>
>      <pattern>%4d{yyyyMMdd-HHmmss} %m%n</pattern>
>    </encoder>
>  </appender>
>
>  <logger name="accessLogger" level="INFO" additivity="false">
>    <appender-ref ref="FILE"/>
>  </logger>
>
>  <root level="${nexus.log.level:-INFO}">
>    <appender-ref ref="FILE"/>
>  </root>
> </configuration>
>
> It doesn't work.  My log entries still show up in the regular nexus.log.
> Or to be precise, only the first entries show up in the new log, but then
> magically subsequent entries go again into nexus.log.
> Only if I re-create the logger using Joran, it kinda works.
>
> Maybe this is all more of a Logback question?
>
> -Max
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: additional logger for plugin in Nexus 2.x?

Max Spring
Hi Tamás,
thanks for your pointers.
I have opted to go with log4j bundled with the plugin.
It gives me a self-contained logging mechanism for producing the access log while my plugin code still can use the slf4j mechanism provided by Nexus for the regular logging.
I can imagine the same would be possible with slf4j + logback.
Regards,
-Max


On 05/10/2012 04:23 AM, Tamás Cservenák wrote:

> Max,
>
> That happens as nexus "reconfigures" the logging in case of some events or such.
>
> Take a peek at LogConfigurationParticipant, I believe what you want is
> a component implementing this iface...
>
> Examples of implementation:
> https://github.com/sonatype/nexus/blob/master/nexus/nexus-logging-extras/src/main/java/org/sonatype/nexus/log/internal/LogbackNexusEventSystemLogConfigurationParticipant.java
>
> Just create a component like this in your plugin, and you should be
> able to "contribute" config to Nexus logging and achieve what you want
> (ultimately, log into separate file if I get you right).
>
> One thing: you would still need to use slf4japi + logback backend, but
> I believe it should not bother you....
>
>
> Thanks,
> ~t~
>
>
> On Wed, May 9, 2012 at 11:59 PM, Max Spring<[hidden email]>  wrote:
>> I'm struggling with Nexus' Slf4j / Logback.
>>
>> I want my plugin to have it's own logger, completely independent from the
>> main logger
>> while re-using Nexus' Logback library, i.e. without having to bundle another
>> logging library.
>>
>> And I don't want to have to manipulate any "global" logging config file --
>> everything should come with the plugin.
>>
>> I'm following the "Invoking JoranConfigurator directly" example from
>> http://logback.qos.ch/manual/joran.html
>> to load my plugin's own logback.xml.
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <configuration>
>>   <appender name="FILE" class="ch.qos.logback.core.FileAppender">
>>     <file>${nexus.log-config-dir}/../logs/access.log</file>
>>     <encoder>
>>       <pattern>%4d{yyyyMMdd-HHmmss} %m%n</pattern>
>>     </encoder>
>>   </appender>
>>
>>   <logger name="accessLogger" level="INFO" additivity="false">
>>     <appender-ref ref="FILE"/>
>>   </logger>
>>
>>   <root level="${nexus.log.level:-INFO}">
>>     <appender-ref ref="FILE"/>
>>   </root>
>> </configuration>
>>
>> It doesn't work.  My log entries still show up in the regular nexus.log.
>> Or to be precise, only the first entries show up in the new log, but then
>> magically subsequent entries go again into nexus.log.
>> Only if I re-create the logger using Joran, it kinda works.
>>
>> Maybe this is all more of a Logback question?
>>
>> -Max
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: additional logger for plugin in Nexus 2.x?

Tamás Cservenák
Yes,

that's what actually does LogConfigurationParticipant, it simply
supplies a separate logback config file, where you can configure
whatever want (like separate log file)....

Thanks,
~t~

On Tue, May 15, 2012 at 6:58 PM, Max Spring <[hidden email]> wrote:

> Hi Tamás,
> thanks for your pointers.
> I have opted to go with log4j bundled with the plugin.
> It gives me a self-contained logging mechanism for producing the access log
> while my plugin code still can use the slf4j mechanism provided by Nexus for
> the regular logging.
> I can imagine the same would be possible with slf4j + logback.
> Regards,
> -Max
>
>
>
> On 05/10/2012 04:23 AM, Tamás Cservenák wrote:
>>
>> Max,
>>
>> That happens as nexus "reconfigures" the logging in case of some events or
>> such.
>>
>> Take a peek at LogConfigurationParticipant, I believe what you want is
>> a component implementing this iface...
>>
>> Examples of implementation:
>>
>> https://github.com/sonatype/nexus/blob/master/nexus/nexus-logging-extras/src/main/java/org/sonatype/nexus/log/internal/LogbackNexusEventSystemLogConfigurationParticipant.java
>>
>> Just create a component like this in your plugin, and you should be
>> able to "contribute" config to Nexus logging and achieve what you want
>> (ultimately, log into separate file if I get you right).
>>
>> One thing: you would still need to use slf4japi + logback backend, but
>> I believe it should not bother you....
>>
>>
>> Thanks,
>> ~t~
>>
>>
>> On Wed, May 9, 2012 at 11:59 PM, Max Spring<[hidden email]>
>>  wrote:
>>>
>>> I'm struggling with Nexus' Slf4j / Logback.
>>>
>>> I want my plugin to have it's own logger, completely independent from the
>>> main logger
>>> while re-using Nexus' Logback library, i.e. without having to bundle
>>> another
>>> logging library.
>>>
>>> And I don't want to have to manipulate any "global" logging config file
>>> --
>>> everything should come with the plugin.
>>>
>>> I'm following the "Invoking JoranConfigurator directly" example from
>>> http://logback.qos.ch/manual/joran.html
>>> to load my plugin's own logback.xml.
>>>
>>> <?xml version="1.0" encoding="UTF-8"?>
>>> <configuration>
>>>  <appender name="FILE" class="ch.qos.logback.core.FileAppender">
>>>    <file>${nexus.log-config-dir}/../logs/access.log</file>
>>>    <encoder>
>>>      <pattern>%4d{yyyyMMdd-HHmmss} %m%n</pattern>
>>>    </encoder>
>>>  </appender>
>>>
>>>  <logger name="accessLogger" level="INFO" additivity="false">
>>>    <appender-ref ref="FILE"/>
>>>  </logger>
>>>
>>>  <root level="${nexus.log.level:-INFO}">
>>>    <appender-ref ref="FILE"/>
>>>  </root>
>>> </configuration>
>>>
>>> It doesn't work.  My log entries still show up in the regular nexus.log.
>>> Or to be precise, only the first entries show up in the new log, but then
>>> magically subsequent entries go again into nexus.log.
>>> Only if I re-create the logger using Joran, it kinda works.
>>>
>>> Maybe this is all more of a Logback question?
>>>
>>> -Max
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [hidden email]
>>> For additional commands, e-mail: [hidden email]
>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: additional logger for plugin in Nexus 2.x?

lnwpenza
This post has NOT been accepted by the mailing list yet.
เกมส์การแข่งขันในปัจจุบันมีหลากหลายแบรน หลายบริษัท แต่แบรนผู้เล่นที่โดดเด่นที่สุดที่ชาวไทยรู้จักกันดี ผลบอล อันดับแรกให้เช็คก่อนว่า คุณมีจำนวนเงินขั้นต่ำพอที่จะถอนหรือไม่ โดยแค่คุณนำไป login เข้าระบบเกมต่างๆ ท่านก็สามารถทดลองเล่น sbo จากที่เราได้เห็นวิธีเล่นการพนันที่เล่นกันง่ายนั่นก็เลยทำให้คนเรานั่นเกิดความคิดที่อยากจะลองเล่นการพนันลองดู gclub online ด้วยที่แทงบอลแบบออนไลน์กำลังมาแรงทำให้พวกโต๊ะบอลเดี๋ยวนี้ก็เริ่มขยับขยายมาเปิดรับแทงบอลออนไลน์เอง ผลบอล เป้าหมายหลักในวิธีเล่นคาสิโนนั้น มีเพื่อความเพลิดเพลินหรือความสนุก ไม่ใช่เพื่อมาหาเงินหรือหวังที่จะรวย ดูผลบอล ตั้งสถานประกอบอยู่ในคาสิโนปอยเปต อย่างเปิดเผย ชัดเจน มีตัวตนจริง
Loading...