This repository has been archived by the owner on Aug 11, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Goal is to make "bundle packaging" (which is basically Jetty + Nexus WAR) use same LogBack instance (as we had problems reported by users in 2.0). Changes: * jetty.xml - umarked "server level" logback as hidden to make it really shared * extracted custom appender into new module nexus-logging-extras-appender that is put top level * nexus-logging-extras got component implementation for EventTarget * logback-events.xml changed to use new appender * bundle assembly changed that exclude all logging relevant JARs from Nexus WAR as they are _provided_ on top level from now on This is WIP, not yet functional.
- Loading branch information
Showing
10 changed files
with
191 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<!-- | ||
Sonatype Nexus (TM) Open Source Version | ||
Copyright (c) 2007-2012 Sonatype, Inc. | ||
All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. | ||
This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, | ||
which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. | ||
Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks | ||
of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the | ||
Eclipse Foundation. All other trademarks are the property of their respective owners. | ||
--> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>org.sonatype.nexus</groupId> | ||
<artifactId>nexus</artifactId> | ||
<version>2.2-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>nexus-logging-extras-appender</artifactId> | ||
<name>Nexus : Logging Extras - Appender</name> | ||
|
||
<dependencies> | ||
<!-- We have components in here --> | ||
<dependency> | ||
<groupId>javax.inject</groupId> | ||
<artifactId>javax.inject</artifactId> | ||
</dependency> | ||
|
||
<!-- Logging --> | ||
<dependency> | ||
<groupId>ch.qos.logback</groupId> | ||
<artifactId>logback-core</artifactId> | ||
<scope>compile</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>ch.qos.logback</groupId> | ||
<artifactId>logback-classic</artifactId> | ||
<scope>compile</scope> | ||
</dependency> | ||
|
||
<!-- Testing --> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit-dep</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
26 changes: 26 additions & 0 deletions
26
...s/nexus-logging-extras-appender/src/main/java/org/sonatype/nexus/logback/EventTarget.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** | ||
* Sonatype Nexus (TM) Open Source Version | ||
* Copyright (c) 2007-2012 Sonatype, Inc. | ||
* All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. | ||
* | ||
* This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, | ||
* which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. | ||
* | ||
* Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks | ||
* of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the | ||
* Eclipse Foundation. All other trademarks are the property of their respective owners. | ||
*/ | ||
package org.sonatype.nexus.logback; | ||
|
||
import ch.qos.logback.classic.spi.ILoggingEvent; | ||
|
||
/** | ||
* An target that receives logging events from {@link ForwardingAppender}. | ||
* | ||
* @author cstamas | ||
* @since 2.2 | ||
*/ | ||
public interface EventTarget | ||
{ | ||
void onEvent( ILoggingEvent event ); | ||
} |
40 changes: 40 additions & 0 deletions
40
...-logging-extras-appender/src/main/java/org/sonatype/nexus/logback/ForwardingAppender.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/** | ||
* Sonatype Nexus (TM) Open Source Version | ||
* Copyright (c) 2007-2012 Sonatype, Inc. | ||
* All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. | ||
* | ||
* This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, | ||
* which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. | ||
* | ||
* Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks | ||
* of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the | ||
* Eclipse Foundation. All other trademarks are the property of their respective owners. | ||
*/ | ||
package org.sonatype.nexus.logback; | ||
|
||
import javax.inject.Inject; | ||
|
||
import ch.qos.logback.classic.spi.ILoggingEvent; | ||
import ch.qos.logback.core.UnsynchronizedAppenderBase; | ||
|
||
/** | ||
* A forwarding appender for Logback, that forwards {@link ILoggingEvent} events it gets as Appender, to it's target. | ||
* | ||
* @author cstamas | ||
* @since 2.2 | ||
*/ | ||
public class ForwardingAppender | ||
extends UnsynchronizedAppenderBase<ILoggingEvent> | ||
{ | ||
@Inject | ||
private EventTarget target; | ||
|
||
@Override | ||
protected void append( final ILoggingEvent event ) | ||
{ | ||
if ( target != null ) | ||
{ | ||
target.onEvent( event ); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
...ing-extras/src/main/java/org/sonatype/nexus/log/internal/NexusEventSystemEventTarget.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/** | ||
* Sonatype Nexus (TM) Open Source Version | ||
* Copyright (c) 2007-2012 Sonatype, Inc. | ||
* All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. | ||
* | ||
* This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, | ||
* which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. | ||
* | ||
* Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks | ||
* of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the | ||
* Eclipse Foundation. All other trademarks are the property of their respective owners. | ||
*/ | ||
package org.sonatype.nexus.log.internal; | ||
|
||
import javax.enterprise.inject.Typed; | ||
import javax.inject.Inject; | ||
import javax.inject.Named; | ||
import javax.inject.Singleton; | ||
|
||
import org.sonatype.nexus.logback.EventTarget; | ||
import org.sonatype.plexus.appevents.ApplicationEventMulticaster; | ||
|
||
import ch.qos.logback.classic.spi.ILoggingEvent; | ||
|
||
/** | ||
* {@link EventTarget} that will multicast the incoming logging event to {@link ApplicationEventMulticaster}. | ||
* | ||
* @author cstamas | ||
* @since 2.2 | ||
*/ | ||
@Named | ||
@Singleton | ||
@Typed( EventTarget.class ) | ||
public class NexusEventSystemEventTarget | ||
implements EventTarget | ||
{ | ||
@Inject | ||
private ApplicationEventMulticaster eventMulticaster; | ||
|
||
@Override | ||
public void onEvent( final ILoggingEvent eventObject ) | ||
{ | ||
if ( eventMulticaster != null ) | ||
{ | ||
final LogbackLoggingEvent logEvent = new LogbackLoggingEvent( eventObject ); | ||
eventMulticaster.notifyEventListeners( logEvent ); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters