Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

NEXUS-5118: Initial imple

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...
commit 349670ddb8fd30d57b8cb1037c61501693dafa82 1 parent e7c7ff3
@cstamas cstamas authored
View
55 nexus/nexus-logging-extras-appender/pom.xml
@@ -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>
View
26 nexus/nexus-logging-extras-appender/src/main/java/org/sonatype/nexus/logback/EventTarget.java
@@ -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 );
+}
View
40 nexus/nexus-logging-extras-appender/src/main/java/org/sonatype/nexus/logback/ForwardingAppender.java
@@ -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 );
+ }
+ }
+}
View
6 nexus/nexus-logging-extras/pom.xml
@@ -26,6 +26,12 @@
<name>Nexus : Logging Extras</name>
<dependencies>
+ <!-- The appender -->
+ <dependency>
+ <groupId>org.sonatype.nexus</groupId>
+ <artifactId>nexus-logging-extras-appender</artifactId>
+ </dependency>
+
<!-- We have components in here -->
<dependency>
<groupId>org.sonatype.sisu</groupId>
View
49 nexus/nexus-logging-extras/src/main/java/org/sonatype/nexus/log/internal/NexusEventSystemEventTarget.java
@@ -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 );
+ }
+ }
+}
View
2  nexus/nexus-logging-extras/src/main/resources/META-INF/log/logback-events.xml
@@ -19,7 +19,7 @@
<included>
- <appender name="events" class="org.sonatype.nexus.log.internal.NexusEventSystemAppender">
+ <appender name="events" class="org.sonatype.nexus.logback.ForwardingAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>WARN</level>
</filter>
View
4 nexus/nexus-oss-webapp/pom.xml
@@ -65,6 +65,10 @@
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.sonatype.nexus</groupId>
+ <artifactId>nexus-logging-extras-appender</artifactId>
+ </dependency>
<!-- The Jetty itself -->
<dependency>
View
4 nexus/nexus-oss-webapp/src/main/assembly/bundle.xml
@@ -91,6 +91,9 @@
<excludes>
<exclude>META-INF/**</exclude>
<exclude>WEB-INF/lib/appcontext*.jar</exclude>
+ <exclude>WEB-INF/lib/slf4j-api*.jar</exclude>
+ <exclude>WEB-INF/lib/logback-core*.jar</exclude>
+ <exclude>WEB-INF/lib/logback-classic*.jar</exclude>
<exclude>WEB-INF/classes/logback.xml</exclude>
</excludes>
</unpackOptions>
@@ -101,6 +104,7 @@
<dependencySet>
<includes>
<include>org.sonatype.nexus:nexus-bootstrap</include>
+ <include>org.sonatype.nexus:nexus-logging-extras-appender</include>
<include>javax.servlet:*</include>
<include>org.eclipse.jetty:*</include>
<include>org.codehaus.plexus:*</include>
View
6 nexus/nexus-oss-webapp/src/main/resources/content/conf/jetty.xml
@@ -51,12 +51,6 @@
<Arg><Ref id="Contexts"/></Arg>
<Arg>${nexus-webapp}</Arg>
<Arg>${nexus-webapp-context-path}</Arg>
- <Set name="serverClasses">
- <Array type="java.lang.String">
- <Item>org.slf4j.</Item>
- <Item>ch.qos.logback.</Item>
- </Array>
- </Set>
<Set name="extractWAR">false</Set>
<Set name="throwUnavailableOnStartupException">true</Set>
</New>
View
6 nexus/pom.xml
@@ -1113,6 +1113,11 @@
</dependency>
<dependency>
<groupId>org.sonatype.nexus</groupId>
+ <artifactId>nexus-logging-extras-appender</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.sonatype.nexus</groupId>
<artifactId>nexus-api</artifactId>
<version>${project.version}</version>
</dependency>
@@ -1803,6 +1808,7 @@
<module>nexus-utils</module>
<module>nexus-web-utils</module>
<module>nexus-logging-extras</module>
+ <module>nexus-logging-extras-appender</module>
<module>nexus-api</module>
<module>nexus-oss-edition</module>
<module>nexus-configuration-model</module>
Please sign in to comment.
Something went wrong with that request. Please try again.