You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by ps...@apache.org on 2008/09/15 05:06:52 UTC

svn commit: r695336 - in /logging/sandbox/jul-to-log4j-bridge/src: changes/changes.xml main/java/org/apache/logging/julbridge/JULBridgeLogManager.java

Author: psmith
Date: Sun Sep 14 20:06:51 2008
New Revision: 695336

URL: http://svn.apache.org/viewvc?rev=695336&view=rev
Log:
Bug 45803 Add ability to configure the bridge using JUL's System property approach, submitted by Brett Randall (thanks!).

Doesn't appear to be an easy way to add a test case for this because the jul.LogManager static block is read once at JVM startup (ideas appreciated).



Added:
    logging/sandbox/jul-to-log4j-bridge/src/main/java/org/apache/logging/julbridge/JULBridgeLogManager.java
Modified:
    logging/sandbox/jul-to-log4j-bridge/src/changes/changes.xml

Modified: logging/sandbox/jul-to-log4j-bridge/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/logging/sandbox/jul-to-log4j-bridge/src/changes/changes.xml?rev=695336&r1=695335&r2=695336&view=diff
==============================================================================
--- logging/sandbox/jul-to-log4j-bridge/src/changes/changes.xml (original)
+++ logging/sandbox/jul-to-log4j-bridge/src/changes/changes.xml Sun Sep 14 20:06:51 2008
@@ -25,6 +25,9 @@
       <action dev="psmith" issue="42664" type="add" due-to="Sagi Mann" due-to-email="sagimann at googlemail.com">
 		Added JULAppender to complete the two-way bridge.
       </action>
+      <action dev="psmith" issue="45803" type="add" due-to="Brett Randall" due-to-email="javabrett at gmail.com">
+          Add custom JUL LogManager to activate JUL Bridge
+      </action>
     </release>
   </body>
 </document>

Added: logging/sandbox/jul-to-log4j-bridge/src/main/java/org/apache/logging/julbridge/JULBridgeLogManager.java
URL: http://svn.apache.org/viewvc/logging/sandbox/jul-to-log4j-bridge/src/main/java/org/apache/logging/julbridge/JULBridgeLogManager.java?rev=695336&view=auto
==============================================================================
--- logging/sandbox/jul-to-log4j-bridge/src/main/java/org/apache/logging/julbridge/JULBridgeLogManager.java (added)
+++ logging/sandbox/jul-to-log4j-bridge/src/main/java/org/apache/logging/julbridge/JULBridgeLogManager.java Sun Sep 14 20:06:51 2008
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable
+ * law or agreed to in writing, software distributed under the License is distributed on an "AS IS"
+ * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
+ * for the specific language governing permissions and limitations under the License.
+ */
+package org.apache.logging.julbridge;
+
+import java.io.IOException;
+
+import org.apache.log4j.LogManager;
+
+/**
+ * Another way to bridge JUL->log4j is be configure custom JUL LogManager class by configuring the <code>java.util.logging.manager</code> system property, so
+ * by specifing this classname as the value for that property you can immediately transfel all JUL events straight into log4j.
+ * 
+ * Just add this to your command-line JVM arguments:
+ * 
+ * <pre>-Djava.util.logging.manager=org.apache.logging.julbridge.JULBridgeLogManager</pre>
+ * 
+ * @author Brett Randall
+ *
+ */
+public class JULBridgeLogManager extends java.util.logging.LogManager {
+
+    public void readConfiguration() throws IOException, SecurityException {
+        JULLog4jBridge.assimilate(LogManager.getLoggerRepository());
+    }
+}
\ No newline at end of file



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org