Skip to content

Commit

Permalink
Merge pull request #7346 from matthiasblaesing/logging
Browse files Browse the repository at this point in the history
Configure commons-logging to log using java.util.logging
  • Loading branch information
ebarboni committed May 3, 2024
2 parents 7cf544c + 04a93a2 commit d108904
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 1 deletion.
20 changes: 19 additions & 1 deletion platform/o.apache.commons.logging/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,31 @@
-->
<project name="platform/o.apache.commons.logging" default="build" basedir=".">
<import file="../../nbbuild/templates/projectized.xml"/>
<target name="jar" depends="-define-FileCRC32Calculator">
<!--
The NetBeans module org.apache.commons.logging is just a repackaging
of the original bundle, the bulk of the module is a verbatim copy of
the original commons-logging.
-->
<target name="jar" depends="-prepare-mandatory-files-for-module,projectized-common.jar,-define-FileCRC32Calculator">
<FileCRC32Calculator file="external/commons-logging-1.3.1.jar" property="o.apache.commons.logging.crc32" />
<jar jarfile="${cluster}/${module.jar}">
<zipfileset src="external/commons-logging-1.3.1.jar"/>
<!--
The module source code consists only of a bundle activator, that
configures commons-logging to log using java.util.logging. The
built classes must be included in the rebuild jar.
-->
<fileset dir="build/classes"
includes="**/*"
excludes="META-INF/LICENSE META-INF/NOTICE"
>
</fileset>
<manifest>
<attribute name="Bundle-SymbolicName" value="org.apache.commons.logging"/>
<attribute name="Bundle-Version" value="1.3.1"/>
<!-- register the BundleActivator, so that commons-logging is propertly configured -->
<attribute name="Bundle-Activator" value="org.netbeans.modules.commonslogging.CommonsLoggingBundleActivator"/>
<attribute name="Import-Package" value="org.osgi.framework"/>
<attribute name="Export-Package" value="org.apache.commons.logging;version=&quot;1.3.1&quot;,org.apache.commons.logging.impl;version=&quot;1.3.1&quot;"/>
<attribute name="NB-Original-CRC" value="${o.apache.commons.logging.crc32}"/>
</manifest>
Expand Down
4 changes: 4 additions & 0 deletions platform/o.apache.commons.logging/nbproject/project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
<runtime-relative-path>org-apache-commons-logging.jar</runtime-relative-path>
<binary-origin>external/commons-logging-1.3.1.jar</binary-origin>
</class-path-extension>
<class-path-extension>
<runtime-relative-path></runtime-relative-path>
<binary-origin>../libs.osgi/external/osgi.core-8.0.0.jar</binary-origin>
</class-path-extension>
</data>
</configuration>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* 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.netbeans.modules.commonslogging;

import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;


public class CommonsLoggingBundleActivator implements BundleActivator {

@Override
public void start(BundleContext bc) throws Exception {
// Configure commons-logging to log using java.util.logging unless
// overridden by the user
if((! System.getProperties().containsKey("org.apache.commons.logging.Log"))
&& (! System.getProperties().containsKey("org.apache.commons.logging.LogFactory"))) {
System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.Jdk14Logger");
System.setProperty("org.apache.commons.logging.LogFactory", "org.apache.commons.logging.impl.LogFactoryImpl");
}
}

@Override
public void stop(BundleContext bc) throws Exception {
}

}

0 comments on commit d108904

Please sign in to comment.