Compare commits

..

35 Commits

Author SHA1 Message Date
Ceki Gulcu 2758a97426 prepare release 1.7.33
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-01-13 15:33:45 +01:00
Ceki Gulcu a0681b72eb fix SLF4J-499
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-01-13 15:16:39 +01:00
Ceki Gulcu c89dc3db0f Merge branch '1.7-maintenance' of github.com:qos-ch/slf4j into 1.7-maintenance 2022-01-12 22:40:47 +01:00
Ceki Gulcu 0d2bd398f7 add slf4j-reload4j module
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-01-12 22:40:10 +01:00
Ceki Gulcu ae9ee009f6 start work on 1.7.33-SNAPSHOT
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2021-07-29 21:31:50 +02:00
Ceki Gulcu 0d8774854f this is version 1.7.32
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2021-07-29 20:27:41 +02:00
Ceki Gulcu 49f242400d make CONFIG_PARAMS aa final field
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2021-07-09 23:02:02 +02:00
Ceki Gulcu e4fd949462 improvements to SLF4J-515
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2021-07-09 09:59:48 +02:00
Ceki Gulcu b6fb6e3b1d changes after feedback from Tibor Digana
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2021-07-09 00:23:22 +02:00
Ceki Gulcu 816da3d857 fixing SLF4J-515
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2021-07-08 23:38:29 +02:00
Ceki Gulcu 33e7bf2b97 start work on 1.7.32
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2021-07-08 20:05:39 +02:00
Ceki Gulcu 502c5286e9 prepare release 1.7.31 2021-06-17 23:32:18 +02:00
Ceki Gulcu 12183e0a1c fix SLF4J-514 2021-06-17 10:59:55 +02:00
Antonio Tomac 940c462556 Avoid potentially "expensive" rendering of message Object to String when log level is disabled SLF4J-497 2021-06-16 00:51:24 +02:00
Ceki Gulcu 62309486d3 next version is 1.7.31 2019-12-20 16:28:48 +01:00
Ceki Gulcu 0b97c416e4 move to 1.7.30 2019-12-16 22:01:36 +01:00
Ceki Gulcu c6c7a98a7e fix SLF4J-469 2019-12-16 21:52:14 +01:00
Ceki Gulcu ca93154c79 do not deploy slf4j-site 2019-10-31 22:16:34 +01:00
Hervé Boutemy d061e25477 this module is Apache 2.0 licensed 2019-10-31 13:08:47 +01:00
Ceki Gulcu e8ce694e2e preapre release 1.7.29 2019-10-31 12:51:26 +01:00
Ceki Gulcu 125e7cca19
Merge pull request #219 from delgurth/1.7-maintenance-with-slf4j-466
SLF4J-466: backport changes to 1.7
2019-08-14 07:46:57 +02:00
Wessel van Norel a7562cb4b9 SLF4J-466: backport changes to 1.7
SLF4J-466: backport changes to 1.7

SLF4J-466: corrected whitespace

SLF4J-466: corrected whitespace
2019-08-14 01:29:58 +02:00
Ceki Gulcu 9752c892fd specify jdk8 in travis 2019-08-10 11:05:48 +02:00
Ceki Gulcu b44fbd53cc prepare release 1.7.28 2019-08-10 10:21:59 +02:00
Ceki Gulcu 2a1374691f correct Automatic-Module-Name: org.apache.log4j 2019-08-10 10:21:11 +02:00
Ceki Gulcu 4c6c574a7a fix javadoc issues 2019-08-06 11:35:23 +02:00
Ceki Gulcu 71291d97ba prepare release 1.7.27 2019-08-06 01:03:12 +02:00
Ceki Gulcu bf50c49d10 fix SLF4J-420 2019-08-06 00:56:24 +02:00
Ceki Gulcu 4e5ddca4ea add Automatic-Module-Name for slf4j-api 2019-08-05 19:03:45 +02:00
Ceki Gulcu e69d4a9c73 fix SLF4J-460 2019-08-05 18:58:53 +02:00
Ceki Gulcu acb850d669 fix link 2019-08-05 18:49:52 +02:00
Ceki Gulcu 179350d855 up version 2019-08-05 18:49:21 +02:00
Ceki Gulcu 7a35058597 rework on site creation, keep Nexus/Central happy 2019-02-19 00:13:52 +01:00
Ceki Gulcu 3cd3f3e5cc enable source jar creation only for select modules to keep Nexus happy 2019-02-18 23:24:43 +01:00
Ceki Gulcu 918a055bdf fix CVE-2018-8088, prepare 1.7.26 release 2019-02-16 13:26:17 +01:00
409 changed files with 19176 additions and 9206 deletions

2
.github/FUNDING.yml vendored
View File

@ -1,2 +0,0 @@
tidelift: maven/org.slf4j:slf4j-api
github: qos-ch

View File

@ -1,47 +0,0 @@
name: CI
on:
push:
branches:
- '*'
pull_request:
branches:
- '*'
# https://help.github.com/en/actions/automating-your-workflow-with-github-actions/software-installed-on-github-hosted-runners
concurrency:
# On master/release, we don't want any jobs cancelled so the sha is used to name the group
# On PR branches, we cancel the job if new commits are pushed
# More info: https://stackoverflow.com/a/68422069/253468
group: ${{ (github.ref == 'refs/heads/branch_1.2.18' || github.ref == 'refs/heads/main' || github.ref == 'refs/heads/release' ) && format('ci-main-{0}', github.sha) || format('ci-main-{0}', github.ref) }}
cancel-in-progress: true
permissions:
contents: read
jobs:
Test:
name: JDK ${{ matrix.jdk }}, ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
jdk: [11, 17, 19]
os: [ubuntu-latest, windows-latest, macos-latest]
fail-fast: true
max-parallel: 4
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 50
- name: Set up Java ${{ matrix.jdk }}
if: ${{ matrix.jdk != '8' }}
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: ${{ matrix.jdk }}
- name: Install
# download dependencies, etc, so test log looks better
run: mvn -B install

View File

@ -1,12 +0,0 @@
<?xml version="1.0" encoding="UTF8"?>
<toolchains>
<toolchain>
<type>jdk</type>
<provides>
<version>1.8</version>
</provides>
<configuration>
<jdkHome>${env.JAVA_HOME_8}</jdkHome>
</configuration>
</toolchain>
</toolchains>

View File

@ -31,8 +31,8 @@
<option name="KEEP_SIMPLE_CLASSES_IN_ONE_LINE" value="true" />
<option name="KEEP_MULTIPLE_EXPRESSIONS_IN_ONE_LINE" value="true" />
<indentOptions>
<option name="INDENT_SIZE" value="4" />
<option name="TAB_SIZE" value="4" />
<option name="INDENT_SIZE" value="2" />
<option name="TAB_SIZE" value="2" />
</indentOptions>
</codeStyleSettings>
<codeStyleSettings language="XML">

View File

@ -1,21 +1,9 @@
dist: trusty
language: java
jdk:
- oraclejdk11
- openjdk8
notifications:
email:
- notification@qos.ch
install: /bin/true
script:
- mvn clean
- mvn install
cache:
directories:
- $HOME/.m2

View File

@ -1 +0,0 @@
github: qos-ch

View File

@ -1,69 +1,14 @@
# About SLF4J
The Simple Logging Facade for Java (SLF4J) serves as a simple facade
or abstraction for various logging frameworks (e.g. java.util.logging,
logback, reload4j, log4j 2.x, logevents, penna, rainbowgum, tinylog)
allowing the end user to plug in the desired logging framework at
deployment time.
The Simple Logging Facade for Java (SLF4J) serves as a simple facade or abstraction for various logging frameworks (e.g. java.util.logging, logback, log4j) allowing the end user to plug in the desired logging framework at deployment time.
More information can be found on the [SLF4J website](http://www.slf4j.org).
# Search org.slf4j artifacts on Maven Central
[![Maven Central](https://img.shields.io/badge/Search%20org%2Eslf4j%20artifacts%20on%20Maven%20Central-2.0.x-green)](https://central.sonatype.com/search?namespace=org.slf4j)
# In case of problems
In case of problems please do not hesitate to post an e-mail message
on the [slf4j-user@qos.ch](https://mailman.qos.ch/cgi-bin/mailman/listinfo/slf4j-user)
mailing list or to start a <a
href="https://github.com/qos-ch/slf4j/discussions">discussion</a> on
github. However, please do not directly e-mail SLF4J developers. The
answer to your question might be useful to other users. Moreover,
there are many knowledgeable users on the slf4j-user mailing lists who
can quickly answer your questions.
# Urgent issues
For urgent issues do not hesitate to [champion a
release](https://github.com/sponsors/qos-ch/sponsorships?tier_id=77436).
In principle, most championed issues are solved within 3 business days
ensued by a release.
# How to build SLF4J
SLF4J uses Maven as its build tool.
SLF4J version 2.0.x will run under Java 8 but requires Java 9 or later to build.
# Build Status
[![Build Status](https://travis-ci.org/qos-ch/slf4j.png)](https://travis-ci.org/qos-ch/slf4j)
# How to contribute pull requests
If you are interested in improving SLF4J, great! The SLF4J community looks forward to your contribution. Please follow this process:
If you are interested in improving SLF4J, that is great! The SLF4J
community looks forward to your contribution. Please follow this
process:
1. Start a discussion on the [slf4j-dev mailing
list](http://www.slf4j.org/mailing-lists.html) about your proposed
change. Alternately, file a [bug
report](https://github.com/qos-ch/slf4j/issues) on github to initiate the
discussion.
2. Fork qos-ch/slf4j. Ideally, create a new branch from your fork for
your contribution to make it easier to merge your changes back.
3. Make your changes on the branch created in Step 2. Be
sure that your code passes existing unit tests. Please add unit tests
for your work if appropriate. It usually is.
4. All commits must have signed off by the contributor attesting to
[Developer Certificate of Origin
(DCO)](https://developercertificate.org/). Commits without sign off
will be automatically rejected by the [DCO GitHub
check](https://probot.github.io/apps/dco/) application.
5. Push your changes to your fork/branch in GitHub. Don't push it to
your master! If you do, it will make it harder to submit new changes
later.
6. Submit a pull request to SLF4J from your commit page on GitHub.
1. Start a discussion on the [slf4j-dev mailing list](http://www.slf4j.org/mailing-lists.html) about your proposed change. Alternately file a [bug report](http://www.slf4j.org/bug-reporting.html).
2. Fork qos-ch/slf4j. Ideally, create a new branch from your fork for your contribution to make it easier to merge your changes back.
3. Make your changes on the branch you hopefuly created in Step 2. Be sure that your code passes existing unit tests. Please add unit tests for your work if appropriate. It usually is.
4. Push your changes to your fork/branch in github. Don't push it to your master! If you do it will make it harder to submit new changes later.
5. Submit a pull request to SLF4J from from your commit page on github.

View File

@ -1,69 +0,0 @@
## Reporting security issues
Please report security issues related to the SLF4J project to the
following email address:
support(at)qos.ch
## Verifying contents
All SLF4J project artifacts published on Maven central are signed. For
each artifact, there is an associated signature file with the .asc
suffix.
### After 2022-08-08
To verify the signature use [this public key](https://www.slf4j.org/public-keys/60200AC4AE761F1614D6C46766D68DAA073BE985.gpg). Here is its fingerprint:
```
pub nistp521 2022-08-08 [SC]
60200AC4AE761F1614D6C46766D68DAA073BE985
uid Ceki Gulcu <ceki@qos.ch>
sub nistp521 2022-08-08 [E]
```
A copy of this key is stored on the
[keys.openpgp.org](https://keys.openpgp.org) keyserver. To add it to
your public key ring use the following command:
```
> FINGER_PRINT=60200AC4AE761F1614D6C46766D68DAA073BE985
> gpg --keyserver hkps://keys.openpgp.org --recv-keys $FINGER_PRINT
```
### Before 2022-08-08
To verify the signature use [this public key](https://www.slf4j.org/public-keys/ceki-public-key.pgp). Here is its fingerprint:
```
pub 2048R/A511E325 2012-04-26
Key fingerprint = 475F 3B8E 59E6 E63A A780 6748 2C7B 12F2 A511 E325
uid Ceki Gulcu <ceki@qos.ch>
sub 2048R/7FBFA159 2012-04-26
```
A copy of this key is stored on the
[keys.openpgp.org](https://keys.openpgp.org) keyserver. To add it to
your public key ring use the following command:
```
> FINGER_PRINT=475F3B8E59E6E63AA78067482C7B12F2A511E325
> gpg --keyserver hkps://keys.openpgp.org --recv-keys $FINGER_PRINT
```
## Preventing commit history overwrite
In order to prevent loss of commit history, developers of the project
are highly encouraged to deny branch deletions or history overwrites
by invoking the following two commands on their local copy of the
repository.
```
git config receive.denyDelete true
git config receive.denyNonFastForwards true
```

View File

@ -18,6 +18,13 @@
<!--<property name="path_to_policy" value="file:./integration/src/policy/java-under-ant.policy"/>-->
<path id="path142Binding">
<pathelement location="target/test-classes/" />
<pathelement location="../slf4j-api/target/slf4j-api-${currentVersion}.jar" />
<pathelement location="./lib/slf4j-simple-1.4.2.jar" />
</path >
<path id="path150Binding">
<pathelement location="target/test-classes/" />
<pathelement location="../slf4j-api/target/slf4j-api-${currentVersion}.jar" />
@ -36,12 +43,32 @@
<pathelement location="./lib/slf4j-simple-1.5.11.jar" />
</path >
<!--<path id="pathIncompatible">
<pathelement location="target/test-classes/" />
<pathelement location="../slf4j-api/target/slf4j-api-${currentVersion}.jar" />
<pathelement location="./lib/slf4j-simple-INCOMPATIBLE.jar" />
</path >
-->
<path id="pathCurrent">
<pathelement location="target/test-classes/" />
<pathelement location="../slf4j-api/target/slf4j-api-${currentVersion}.jar" />
<pathelement location="../slf4j-simple/target/slf4j-simple-${currentVersion}.jar" />
</path >
<path id="pathNoBinding">
<pathelement location="target/test-classes/" />
<pathelement location="../slf4j-api/target/slf4j-api-${currentVersion}.jar" />
</path >
<path id="incompatibleMultiBinding">
<pathelement location="target/test-classes/" />
<pathelement location="../slf4j-api/target/slf4j-api-${currentVersion}.jar" />
<pathelement location="./lib/slf4j-simple-1.5.0.jar" />
<pathelement location="./lib/slf4j-nop-1.5.6.jar" />
</path >
<path id="multiBinding">
<pathelement location="target/test-classes/" />
<pathelement location="../slf4j-api/target/slf4j-api-${currentVersion}.jar" />
@ -72,33 +99,41 @@
<!-- this is really very ugly, but it's the only way to circumvent
http://jira.codehaus.org/browse/MANTRUN-95
-->
<!--
<taskdef name="junit" classpath="${plugin_classpath};${compile_classpath}"
classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask" />
-->
<target name="init">
<mkdir dir="target/unit-reports" />
</target>
<target name="testAll" depends="init,
testNoProvider150,
testMissingSingletonMethod,
testMismatch,
testMatch,
testMultiBinding,
testFuture_16Series"
>
testNoBinding,
testMatch,
testMultiBinding,
testIncompatibleMultiBinding,
testFuture_16Series,
testActiveSecurityManager">
</target>
<target name="testNoProvider150">
<target name="testMissingSingletonMethod">
<junit printsummary="yes" fork="no" haltonfailure="yes">
<junit printsummary="yes" fork="no" haltonfailure="yes">
<classpath refid="path142Binding" />
<formatter type="plain" />
<test fork="yes" todir="target/unit-reports"
outfile="TEST-142BININDING"
name="org.slf4j.MissingSingletonMethodAssertionTest" />
</junit>
<junit printsummary="yes" fork="no" haltonfailure="yes">
<classpath refid="path150Binding" />
<formatter type="plain" />
<test fork="yes" todir="target/unit-reports"
outfile="TEST-150BINDING"
name="org.slf4j.NoProviderAssertionTest" />
name="org.slf4j.MissingSingletonMethodAssertionTest" />
</junit>
</target>
@ -118,18 +153,15 @@
<target name="testMismatch">
<!--
<junit printsummary="yes" fork="no" haltonfailure="yes">
<classpath refid="path1511API" />
<formatter type="plain" />
<test fork="yes" todir="target/unit-reports"
outfile="TEST-MISMATCH-1511API"
name="org.slf4j.OldAPIVersionMismatchAssertionTest" />
name="org.slf4j.VersionMismatchAssertionTest" />
</junit>
-->
<!--
<junit printsummary="yes" fork="no" haltonfailure="yes">
<classpath refid="path1511Binding" />
<formatter type="plain" />
@ -137,7 +169,6 @@
outfile="TEST-MISMATCH-1511Binding"
name="org.slf4j.VersionMismatchAssertionTest" />
</junit>
-->
</target>
@ -149,7 +180,16 @@
outfile="TEST-Match"
name="org.slf4j.CompatibilityAssertionTest" />
</junit>
</target>
<target name="testIncompatibleMultiBinding">
<junit printsummary="yes" fork="no" haltonfailure="yes">
<classpath refid="incompatibleMultiBinding" />
<formatter type="plain" />
<test fork="yes" todir="target/unit-reports"
outfile="TEST-IncompatibleMultiBinding"
name="org.slf4j.IncompatibleMultiBindingAssertionTest" />
</junit>
</target>
<target name="testMultiBinding">
@ -162,17 +202,13 @@
</junit>
</target>
<target name="testFuture_16Series">
<!-- 1.8 uses providers and no longer supports bindings ==
<junit printsummary="yes" fork="no" haltonfailure="yes">
<junit printsummary="yes" fork="no" haltonfailure="yes">
<classpath refid="binding166" />
<formatter type="plain" />
<test fork="yes" todir="target/unit-reports"
outfile="TEST-binding166"
name="org.slf4j.NoProviderAssertionTest" />
name="org.slf4j.CompatibilityAssertionTest" />
</junit>
@ -183,9 +219,19 @@
outfile="TEST-api166"
name="org.slf4j.CompatibilityAssertionTest" />
</junit>
-->
</target>
</target>
<target name="testNoBinding">
<junit printsummary="yes" fork="no" haltonfailure="yes">
<classpath refid="pathNoBinding" />
<formatter type="plain" />
<test fork="yes" todir="target/unit-reports"
outfile="TEST-NOBINDING"
name="org.slf4j.helpers.NoBindingMultithreadedInitializationTest2" />
</junit>
</target>
<condition property="runFromWithinIntegrationModule">
<contains string="${user.dir}" substring="integration" />
@ -201,7 +247,7 @@
<property name="path_to_policy" value="file:./src/policy/java-under-ant.policy"/>
</target>
<!-- no longer supported in JDK 24 and later -->
<target name="testActiveSecurityManager" depends="setPathToPolicy_FromTop, setPathToPolicy_FromIntegration">
<junit printsummary="yes" fork="no" haltonfailure="yes">
<jvmarg value="-Djava.security.manager"/>

36
integration/osgi-build.xml Executable file → Normal file
View File

@ -13,22 +13,15 @@
<echo message="test classpath: ${test_classpath}" />
<echo message="basedir: ${basedir}" />
<echo message="ant.java.version: ${ant.java.version}" />
<property name="iBundleJar" value="target/iBundle.jar"/>
<property name="bundlesDir" value="bundle"/>
<!-- this is really very ugly, but it's the only way to circumvent
http://jira.codehaus.org/browse/MANTRUN-95
-->
<taskdef name="junit" classpath="${test_classpath}"
classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask" />
-->
<condition property="jdk9">
<matches pattern="9.*" string="${ant.java.version}" />
</condition>
<path id="minimal">
<pathelement location="target/test-classes/" />
@ -66,45 +59,34 @@
<!-- for some reason if mvn is invoked from the parent directory, junit gets
invoked from the parent dir, which messes up these tests. Hence, the
invoked from the parent dir, which messes up theses tests. Hence, the
fork="yes" dir="${basedir}" -->
<!--
<jvmarg line="MINUS_MINUSadd-opens java.base/java.net=ALL-UNNAMED"/>
<jvmarg line="MINUS_MINUSadd-opens java.base/java.security=ALL-UNNAMED"/>
-->
<target name="nop" unless="jdk9">
<target name="nop">
<prepareOSGiHarness binding="nop"/>
<junit printsummary="yes" fork="yes" dir="${basedir}" haltonfailure="yes">
<classpath path="${test_classpath}"/>
<formatter type="plain" />
<test todir="target/unit-reports"
name="org.slf4j.test_osgi.BundleTest"
outfile="OSGI-nop" />
<test fork="yes" todir="target/unit-reports" name="org.slf4j.test_osgi.BundleTest" />
</junit>
</target>
<target name="simple" unless="jdk9">
<target name="simple">
<prepareOSGiHarness binding="simple"/>
<junit printsummary="yes" fork="yes" dir="${basedir}" haltonfailure="yes">
<classpath path="${test_classpath}"/>
<formatter type="plain" />
<test fork="yes" todir="target/unit-reports"
name="org.slf4j.test_osgi.BundleTest"
outfile="OSGI-simple" />
<test fork="yes" todir="target/unit-reports" name="org.slf4j.test_osgi.BundleTest" />
</junit>
</target>
<target name="jdk14" unless="jdk9">
<target name="jdk14">
<prepareOSGiHarness binding="jdk14"/>
<junit printsummary="yes" fork="yes" dir="${basedir}" haltonfailure="yes">
<classpath path="${test_classpath}"/>
<formatter type="plain" />
<test fork="yes" todir="target/unit-reports"
name="org.slf4j.test_osgi.BundleTest"
outfile="OSGI-jdk14"/>
<test fork="yes" todir="target/unit-reports" name="org.slf4j.test_osgi.BundleTest" />
</junit>
</target>
</project>
</project>

View File

@ -7,8 +7,7 @@
<parent>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-parent</artifactId>
<version>2.0.19-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
<version>1.7.33</version>
</parent>
<artifactId>integration</artifactId>
@ -18,14 +17,6 @@
<url>http://www.slf4j.org</url>
<description>SLF4J integration tests</description>
<properties>
<junit.version>4.10</junit.version>
<!-- 1.9.1 does not work. Do not update lightly -->
<ant-junit.version>1.9.0</ant-junit.version>
<antrun-plugin.version>1.8</antrun-plugin.version>
</properties>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
@ -33,21 +24,17 @@
</dependency>
<!-- declaration to circumvent http://jira.codehaus.org/browse/MANTRUN-95 -->
<!--
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit3.version}</version>
<version>3.8.1</version>
</dependency>
-->
<!-- declaration to circumvent http://jira.codehaus.org/browse/MANTRUN-95 -->
<!--
<dependency>
<groupId>ant</groupId>
<artifactId>ant-junit</artifactId>
<version>${ant-junit.version}</version>
<version>1.6.5</version>
</dependency>
-->
<!-- some test run Felix in hosted mode -->
<dependency>
@ -62,17 +49,17 @@
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>${antrun-plugin.version}</version>
<version>1.2</version>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<version>3.8.1</version>
</dependency>
<dependency>
<groupId>org.apache.ant</groupId>
<groupId>ant</groupId>
<artifactId>ant-junit</artifactId>
<version>${ant-junit.version}</version>
<version>1.6.5</version>
</dependency>
</dependencies>
<executions>
@ -93,7 +80,6 @@
<goal>run</goal>
</goals>
</execution>
<!-- OSGI integration with ServiceLoader mechanism fails at this stage
<execution>
<id>ant-osgi-test</id>
<phase>package</phase>
@ -109,7 +95,7 @@
<goal>run</goal>
</goals>
</execution>
-->
</executions>
</plugin>
@ -125,19 +111,9 @@
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</project>
</project>

View File

@ -10,6 +10,6 @@ Implementation-Title: iBundle
Bundle-ManifestVersion: 2
Bundle-SymbolicName: iBundle
Bundle-Name: abundle
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Export-Package: apack
Import-Package: org.osgi.framework, org.slf4j;version=1.5

View File

@ -25,47 +25,37 @@
package org.slf4j;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.slf4j.helpers.Reporter.SLF4J_INTERNAL_VERBOSITY_KEY;
import java.io.PrintStream;
import java.util.Random;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import junit.framework.TestCase;
public class CompatibilityAssertionTest {
public class CompatibilityAssertionTest extends TestCase {
StringPrintStream sps = new StringPrintStream(System.err);
PrintStream old = System.err;
int diff = 1024 + new Random().nextInt(10000);
@Before
public void setUp() throws Exception {
System.setProperty(SLF4J_INTERNAL_VERBOSITY_KEY, "debug");
public CompatibilityAssertionTest(String name) {
super(name);
}
protected void setUp() throws Exception {
super.setUp();
System.setErr(sps);
}
@After
public void tearDown() throws Exception {
System.clearProperty(SLF4J_INTERNAL_VERBOSITY_KEY);
protected void tearDown() throws Exception {
super.tearDown();
System.setErr(old);
}
@Test
public void test() throws Exception {
Logger logger = LoggerFactory.getLogger(this.getClass());
String msg = "hello world " + diff;
logger.info(msg);
assertEquals(2, sps.stringList.size());
assertEquals(1, sps.stringList.size());
String s0 = (String) sps.stringList.get(0);
assertTrue(s0.startsWith("SLF4J(D): Connected with provider of type [org.slf4j.simple.SimpleServiceProvider]"));
String s1 = (String) sps.stringList.get(1);
assertTrue(s1.contains(msg));
assertTrue(s0.contains(msg));
}
}

View File

@ -24,35 +24,33 @@
*/
package org.slf4j;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.PrintStream;
import java.util.List;
import java.util.Random;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import junit.framework.TestCase;
public class IncompatibleMultiBindingAssertionTest {
public class IncompatibleMultiBindingAssertionTest extends TestCase {
StringPrintStream sps = new StringPrintStream(System.err);
PrintStream old = System.err;
int diff = 1024 + new Random().nextInt(10000);
@Before
public void setUp() throws Exception {
public IncompatibleMultiBindingAssertionTest(String name) {
super(name);
}
protected void setUp() throws Exception {
super.setUp();
System.setErr(sps);
}
@After
public void tearDown() throws Exception {
protected void tearDown() throws Exception {
super.tearDown();
System.setErr(old);
}
@Test
public void smoke() throws Exception {
public void test() throws Exception {
try {
Logger logger = LoggerFactory.getLogger(this.getClass());
String msg = "hello world " + diff;

View File

@ -0,0 +1,83 @@
/**
* Copyright (c) 2004-2016 QOS.ch
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
package org.slf4j;
import java.io.PrintStream;
import java.util.Random;
import junit.framework.TestCase;
public class MissingSingletonMethodAssertionTest extends TestCase {
StringPrintStream sps = new StringPrintStream(System.err);
PrintStream old = System.err;
int diff = 1024 + new Random().nextInt(10000);
public MissingSingletonMethodAssertionTest(String name) {
super(name);
}
protected void setUp() throws Exception {
super.setUp();
System.setErr(sps);
}
protected void tearDown() throws Exception {
super.tearDown();
System.setErr(old);
}
public void test() throws Exception {
try {
Logger logger = LoggerFactory.getLogger(this.getClass());
String msg = "hello world " + diff;
logger.info(msg);
fail("NoSuchMethodError expected");
} catch (NoSuchMethodError e) {
}
int lineCount = sps.stringList.size();
assertTrue("number of lines should be 3 but was " + lineCount, lineCount == 3);
// expected output:
// SLF4J: slf4j-api 1.6.x (or later) is incompatible with this binding.
// SLF4J: Your binding is version 1.4.x or earlier.
// SLF4J: Upgrade your binding to version 1.6.x. or 2.0.x
{
String s = (String) sps.stringList.get(0);
assertTrue(s.contains("SLF4J: slf4j-api 1.6.x (or later) is incompatible with this binding."));
}
{
String s = (String) sps.stringList.get(1);
assertTrue(s.contains("SLF4J: Your binding is version 1.5.5 or earlier."));
}
{
String s = (String) sps.stringList.get(2);
assertTrue(s.contains("SLF4J: Upgrade your binding to version 1.6.x."));
}
}
}

View File

@ -28,40 +28,38 @@ import java.io.PrintStream;
import java.util.List;
import java.util.Random;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertTrue;
import junit.framework.TestCase;
public class MultiBindingAssertionTest {
public class MultiBindingAssertionTest extends TestCase {
StringPrintStream sps = new StringPrintStream(System.err);
PrintStream old = System.err;
int diff = 1024 + new Random().nextInt(10000);
@Before
public void setUp() throws Exception {
public MultiBindingAssertionTest(String name) {
super(name);
}
protected void setUp() throws Exception {
super.setUp();
System.setErr(sps);
}
@After
public void tearDown() throws Exception {
protected void tearDown() throws Exception {
super.tearDown();
System.setErr(old);
}
@Test
public void test() throws Exception {
Logger logger = LoggerFactory.getLogger(this.getClass());
String msg = "hello world " + diff;
logger.info(msg);
List<String> list = sps.stringList;
int line = 0;
assertMsgContains(list, line++, "Class path contains multiple SLF4J providers.");
assertMsgContains(list, line++, "Found provider");
assertMsgContains(list, line++, "Found provider");
assertMsgContains(list, line++, "See https://www.slf4j.org/codes.html#multiple_bindings for an explanation.");
//assertMsgContains(list, line++, "SLF4J(D): Connected with provider of type [");
assertMsgContains(list, 0, "Class path contains multiple SLF4J bindings.");
assertMsgContains(list, 1, "Found binding in");
assertMsgContains(list, 2, "Found binding in");
assertMsgContains(list, 3, "See http://www.slf4j.org/codes.html");
assertMsgContains(list, 4, "Actual binding is of type [");
}
void assertMsgContains(List<String> strList, int index, String msg) {

View File

@ -1,54 +0,0 @@
package org.slf4j;
import static junit.framework.Assert.assertTrue;
public class OutputVerifier {
static void noProvider(StringPrintStream sps) {
dump(sps);
int lineCount = sps.stringList.size();
assertTrue("number of lines should be 6 but was " + lineCount, lineCount == 6);
// expected output: (version 1.8)
// SLF4J: No SLF4J providers were found.
// SLF4J: Defaulting to no-operation (NOP) logger implementation
// SLF4J: See http://www.slf4j.org/codes.html#noProviders for further details.
// SLF4J: Class path contains SLF4J bindings targeting slf4j-api versions prior to 1.8.
// SLF4J: Ignoring binding found at
// [jar:file:..../slf4j-simple-1.4.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
// SLF4J: See http://www.slf4j.org/codes.html#ignoredBindings for an explanation.
{
String s = (String) sps.stringList.get(0);
assertTrue(s.contains("No SLF4J providers were found."));
}
{
String s = (String) sps.stringList.get(1);
assertTrue(s.contains("Defaulting to no-operation (NOP) logger implementation"));
}
{
String s = (String) sps.stringList.get(2);
assertTrue(s.contains("See https://www.slf4j.org/codes.html#noProviders for further details."));
}
{
String s = (String) sps.stringList.get(3);
assertTrue(s.contains("Class path contains SLF4J bindings targeting slf4j-api versions 1.7.x or earlier."));
}
{
String s = (String) sps.stringList.get(4);
assertTrue(s.contains("Ignoring binding found at"));
}
{
String s = (String) sps.stringList.get(5);
assertTrue(s.contains("See https://www.slf4j.org/codes.html#ignoredBindings for an explanation"));
}
}
public static void dump(StringPrintStream sps) {
for (String s : sps.stringList) {
System.out.println(s);
}
}
}

View File

@ -32,7 +32,7 @@ public class StringPrintStream extends PrintStream {
public static final String LINE_SEP = System.getProperty("line.separator");
PrintStream other;
List<String> stringList = new ArrayList<>();
List<String> stringList = new ArrayList<String>();
public StringPrintStream(PrintStream ps) {
super(ps);

View File

@ -24,39 +24,36 @@
*/
package org.slf4j;
import static org.junit.Assert.assertTrue;
import java.io.PrintStream;
import java.util.Random;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import junit.framework.TestCase;
public class OldAPIVersionMismatchAssertionTest {
public class VersionMismatchAssertionTest extends TestCase {
StringPrintStream sps = new StringPrintStream(System.err);
PrintStream old = System.err;
int diff = 1024 + new Random().nextInt(10000);
@Before
public void setUp() throws Exception {
public VersionMismatchAssertionTest(String name) {
super(name);
}
protected void setUp() throws Exception {
super.setUp();
System.setErr(sps);
}
@After
public void tearDown() throws Exception {
protected void tearDown() throws Exception {
super.tearDown();
System.setErr(old);
}
@Test
public void test() throws Exception {
Logger logger = LoggerFactory.getLogger(this.getClass());
String msg = "hello world " + diff;
logger.info(msg);
OutputVerifier.dump(sps);
String s0 = (String) sps.stringList.get(0);
assertTrue(s0.matches("SLF4J: The requested version .* by your slf4j binding is not compatible with.*"));

View File

@ -1,5 +1,5 @@
/**
* Copyright (c) 2021 QOS.ch
* Copyright (c) 2004-2016 QOS.ch
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
@ -22,47 +22,44 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
package org.slf4j.rule;
package org.slf4j.helpers;
import org.junit.runners.model.Statement;
import java.util.List;
import java.util.concurrent.CyclicBarrier;
import java.util.concurrent.atomic.AtomicLong;
//This class has been inspired by the article "A JUnit Rule to Run a Test in Its Own Thread"
//published by Frank Appel, author of the book "Testing with JUnit" published by Packt publishing.
//
//See also
//https://www.codeaffine.com/2014/07/21/a-junit-rule-to-run-a-test-in-its-own-thread/
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class RunInNewThreadStatement extends Statement implements Runnable {
final Statement base;
final long timeout;
Throwable throwable;
public class LoggerAccessingThread2 extends Thread {
private static int LOOP_LEN = 64;
RunInNewThreadStatement(Statement base, long timeout) {
this.base = base;
this.timeout = timeout;
}
final CyclicBarrier barrier;
final int count;
final AtomicLong eventCount;
List<Logger> loggerList;
@Override
public void evaluate() throws Throwable {
Thread thread = new Thread(this);
thread.start();
System.out.println("Timeout is "+timeout);
thread.join(timeout);
if (throwable != null) {
throw throwable;
}
public LoggerAccessingThread2(final CyclicBarrier barrier, List<Logger> loggerList, final int count, final AtomicLong eventCount) {
this.barrier = barrier;
this.loggerList = loggerList;
this.count = count;
this.eventCount = eventCount;
}
@Override
public void run() {
try {
base.evaluate();
} catch (Throwable e) {
this.throwable = e;
barrier.await();
} catch (Exception e) {
e.printStackTrace();
}
String loggerNamePrefix = this.getClass().getName();
for (int i = 0; i < LOOP_LEN; i++) {
Logger logger = LoggerFactory.getLogger(loggerNamePrefix + "-" + count + "-" + i);
loggerList.add(logger);
Thread.yield();
logger.info("in run method");
eventCount.getAndIncrement();
}
}
}

View File

@ -0,0 +1,112 @@
/**
* Copyright (c) 2004-2016 QOS.ch
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
package org.slf4j.helpers;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import java.util.concurrent.BrokenBarrierException;
import java.util.concurrent.CyclicBarrier;
import java.util.concurrent.atomic.AtomicLong;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.event.EventRecodingLogger;
import junit.framework.TestCase;
public class NoBindingMultithreadedInitializationTest2 extends TestCase {
final protected static int THREAD_COUNT = 4 + Runtime.getRuntime().availableProcessors() * 2;
private final List<Logger> createdLoggers = Collections.synchronizedList(new ArrayList<Logger>());
protected final AtomicLong eventCount = new AtomicLong(0);
final private CyclicBarrier barrier = new CyclicBarrier(THREAD_COUNT + 1);
int diff = new Random().nextInt(10000);
public NoBindingMultithreadedInitializationTest2(String name) {
super(name);
}
public void testNoBindingMultiThreadedInitialization() throws InterruptedException, BrokenBarrierException {
@SuppressWarnings("unused")
LoggerAccessingThread2[] accessors = harness();
Logger logger = LoggerFactory.getLogger(getClass().getName());
logger.info("hello");
eventCount.getAndIncrement();
assertAllSubstLoggersAreFixed();
long recordedEventCount = getRecordedEventCount();
int LENIENCY_COUNT = 16;
long expectedEventCount = eventCount.get() + extraLogEvents();
assertTrue(expectedEventCount + " >= " + recordedEventCount, expectedEventCount >= recordedEventCount);
assertTrue(expectedEventCount + " < " + recordedEventCount + "+" + LENIENCY_COUNT,
expectedEventCount < recordedEventCount + LENIENCY_COUNT);
}
protected int extraLogEvents() {
return 0;
}
private void assertAllSubstLoggersAreFixed() {
for (Logger logger : createdLoggers) {
if (logger instanceof SubstituteLogger) {
SubstituteLogger substLogger = (SubstituteLogger) logger;
if (substLogger.delegate() instanceof EventRecodingLogger)
fail("substLogger " + substLogger.getName() + " has a delegate of type EventRecodingLogger");
}
}
}
private LoggerAccessingThread2[] harness() throws InterruptedException, BrokenBarrierException {
LoggerAccessingThread2[] threads = new LoggerAccessingThread2[THREAD_COUNT];
for (int i = 0; i < THREAD_COUNT; i++) {
threads[i] = new LoggerAccessingThread2(barrier, createdLoggers, i, eventCount);
threads[i].start();
}
// trigger barrier
barrier.await();
for (int i = 0; i < THREAD_COUNT; i++) {
threads[i].join();
}
return threads;
}
final String loggerName = this.getClass().getName();
protected long getRecordedEventCount() {
return eventCount.get();
}
}

View File

@ -7,7 +7,7 @@ import junit.framework.TestCase;
public class Issue324Test extends TestCase {
public void testLoggerCreationInPresenceOfSecurityManager() {
public void testLoggerCreationInPresenseOfSecurityManager() {
String currentDir = System.getProperty("user.dir");
System.out.println("currentDir:" + currentDir);
Logger logger = LoggerFactory.getLogger(Issue324Test.class);

View File

@ -33,7 +33,7 @@ import org.osgi.framework.BundleListener;
public class CheckingBundleListener implements BundleListener {
List<BundleEvent> eventList = new ArrayList<>();
List<BundleEvent> eventList = new ArrayList<BundleEvent>();
public void bundleChanged(BundleEvent be) {
eventList.add(be);
@ -45,14 +45,16 @@ public class CheckingBundleListener implements BundleListener {
}
public void dumpAll() {
for (BundleEvent fe : eventList) {
for (int i = 0; i < eventList.size(); i++) {
BundleEvent fe = (BundleEvent) eventList.get(i);
dump(fe);
}
}
boolean exists(String bundleName) {
for (BundleEvent bundleEvent : eventList) {
Bundle b = bundleEvent.getBundle();
for (int i = 0; i < eventList.size(); i++) {
BundleEvent fe = (BundleEvent) eventList.get(i);
Bundle b = fe.getBundle();
System.out.println("===[" + b + "]");
if (bundleName.equals(b.getSymbolicName())) {
return true;

View File

@ -75,7 +75,7 @@ public class FelixHost {
try {
// Create host activator;
List<Object> list = new ArrayList<>();
List<Object> list = new ArrayList<Object>();
// list.add(new HostActivator());
configMap.put(Constants.FRAMEWORK_SYSTEMPACKAGES_EXTRA, "org.xml.sax, org.xml.sax.helpers, javax.xml.parsers, javax.naming");

View File

@ -32,9 +32,8 @@ import org.osgi.framework.FrameworkListener;
public class FrameworkErrorListener implements FrameworkListener {
public List<FrameworkEvent> errorList = new ArrayList<>();
public List<FrameworkEvent> errorList = new ArrayList<FrameworkEvent>();
@Override
public void frameworkEvent(FrameworkEvent fe) {
if (fe.getType() == FrameworkEvent.ERROR) {
errorList.add(fe);
@ -55,8 +54,9 @@ public class FrameworkErrorListener implements FrameworkListener {
}
public void dumpAll() {
for (FrameworkEvent frameworkEvent : errorList) {
dump(frameworkEvent);
for (int i = 0; i < errorList.size(); i++) {
FrameworkEvent fe = (FrameworkEvent) errorList.get(i);
dump(fe);
}
}
}

View File

@ -5,8 +5,7 @@
<parent>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-parent</artifactId>
<version>2.0.19-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
<version>1.7.33</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -19,16 +18,12 @@
<licenses>
<license>
<name>Apache-2.0</name>
<name>Apache License, Version 2.0</name>
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>
<properties>
<module-name>org.apache.commons.logging</module-name>
</properties>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
@ -40,19 +35,6 @@
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<configuration>
<instructions>
<_exportcontents>org.apache.commons.logging*;version=${jcl.version};-noimport:=true</_exportcontents>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -20,7 +20,7 @@ package org.apache.commons.logging;
* <p>A simple logging interface abstracting logging APIs. In order to be
* instantiated successfully by {@link LogFactory}, classes that implement
* this interface must have a constructor that takes a single String
* parameter representing the "name" of this Log.
* parameter representing the "name" of this Log.</p>
*
* <p> The six logging levels used by <code>Log</code> are (in order):
* <ol>
@ -34,27 +34,27 @@ package org.apache.commons.logging;
* The mapping of these log levels to the concepts used by the underlying
* logging system is implementation dependent.
* The implementation should ensure, though, that this ordering behaves
* as expected.
* as expected.</p>
*
* <p>Performance is often a logging concern.
* By examining the appropriate property,
* a component can avoid expensive operations (producing information
* to be logged).
* to be logged).</p>
*
* <p> For example,
* <pre>
* <code><pre>
* if (log.isDebugEnabled()) {
* ... do something expensive ...
* log.debug(theResult);
* }
* </pre>
*
* </pre></code>
* </p>
*
* <p>Configuration of the underlying logging system will generally be done
* external to the Logging APIs, through whatever mechanism is supported by
* that system.
* that system.</p>
*
* <p style="color: #E40; font-weight: bold;">Please note that this interface is identical to that found in JCL 1.1.1.
* <p style="color: #E40; font-weight: bold;">Please note that this interface is identical to that found in JCL 1.1.1.</p>
*
* @author <a href="mailto:sanders@apache.org">Scott Sanders</a>
* @author Rod Waldhoff
@ -65,74 +65,74 @@ public interface Log {
// ----------------------------------------------------- Logging Properties
/**
* <p> Is debug logging currently enabled?
* <p> Is debug logging currently enabled? </p>
*
* <p> Call this method to prevent having to perform expensive operations
* (for example, <code>String</code> concatenation)
* when the log level is more than debug.
* when the log level is more than debug. </p>
*/
public boolean isDebugEnabled();
/**
* <p> Is error logging currently enabled?
* <p> Is error logging currently enabled? </p>
*
* <p> Call this method to prevent having to perform expensive operations
* (for example, <code>String</code> concatenation)
* when the log level is more than error.
* when the log level is more than error. </p>
*/
public boolean isErrorEnabled();
/**
* <p> Is fatal logging currently enabled?
* <p> Is fatal logging currently enabled? </p>
*
* <p> Call this method to prevent having to perform expensive operations
* (for example, <code>String</code> concatenation)
* when the log level is more than fatal.
* when the log level is more than fatal. </p>
*/
public boolean isFatalEnabled();
/**
* <p> Is info logging currently enabled?
* <p> Is info logging currently enabled? </p>
*
* <p> Call this method to prevent having to perform expensive operations
* (for example, <code>String</code> concatenation)
* when the log level is more than info.
* when the log level is more than info. </p>
*
* @return true if info enabled, false otherwise
*/
public boolean isInfoEnabled();
/**
* <p> Is trace logging currently enabled?
* <p> Is trace logging currently enabled? </p>
*
* <p> Call this method to prevent having to perform expensive operations
* (for example, <code>String</code> concatenation)
* when the log level is more than trace.
* when the log level is more than trace. </p>
*
* @return true if trace enabled, false otherwise
*/
public boolean isTraceEnabled();
/**
* <p> Is warn logging currently enabled?
* <p> Is warn logging currently enabled? </p>
*
* <p> Call this method to prevent having to perform expensive operations
* (for example, <code>String</code> concatenation)
* when the log level is more than warn.
* when the log level is more than warn. </p>
*/
public boolean isWarnEnabled();
// -------------------------------------------------------- Logging Methods
/**
* <p> Log a message with trace log level.
* <p> Log a message with trace log level. </p>
*
* @param message log this message
*/
public void trace(Object message);
/**
* <p> Log an error with trace log level.
* <p> Log an error with trace log level. </p>
*
* @param message log this message
* @param t log this cause
@ -140,14 +140,14 @@ public interface Log {
public void trace(Object message, Throwable t);
/**
* <p> Log a message with debug log level.
* <p> Log a message with debug log level. </p>
*
* @param message log this message
*/
public void debug(Object message);
/**
* <p> Log an error with debug log level.
* <p> Log an error with debug log level. </p>
*
* @param message log this message
* @param t log this cause
@ -155,14 +155,14 @@ public interface Log {
public void debug(Object message, Throwable t);
/**
* <p> Log a message with info log level.
* <p> Log a message with info log level. </p>
*
* @param message log this message
*/
public void info(Object message);
/**
* <p> Log an error with info log level.
* <p> Log an error with info log level. </p>
*
* @param message log this message
* @param t log this cause
@ -170,14 +170,14 @@ public interface Log {
public void info(Object message, Throwable t);
/**
* <p> Log a message with warn log level.
* <p> Log a message with warn log level. </p>
*
* @param message log this message
*/
public void warn(Object message);
/**
* <p> Log an error with warn log level.
* <p> Log an error with warn log level. </p>
*
* @param message log this message
* @param t log this cause
@ -185,14 +185,14 @@ public interface Log {
public void warn(Object message, Throwable t);
/**
* <p> Log a message with error log level.
* <p> Log a message with error log level. </p>
*
* @param message log this message
*/
public void error(Object message);
/**
* <p> Log an error with error log level.
* <p> Log an error with error log level. </p>
*
* @param message log this message
* @param t log this cause
@ -200,14 +200,14 @@ public interface Log {
public void error(Object message, Throwable t);
/**
* <p> Log a message with fatal log level.
* <p> Log a message with fatal log level. </p>
*
* @param message log this message
*/
public void fatal(Object message);
/**
* <p> Log an error with fatal log level.
* <p> Log an error with fatal log level. </p>
*
* @param message log this message
* @param t log this cause

View File

@ -21,7 +21,7 @@ package org.apache.commons.logging;
* An exception that is thrown only if a suitable <code>LogFactory</code> or
* <code>Log</code> instance cannot be created by the corresponding factory
* methods.
*
* </p>
*
* <p>
* In this version of JCL, this exception will never be thrown in practice.

View File

@ -25,7 +25,7 @@ import org.apache.commons.logging.impl.SLF4JLogFactory;
* Factory for creating {@link Log} instances, which always delegates to an
* instance of {@link SLF4JLogFactory}.
*
*
* </p>
*
* @author Craig R. McClanahan
* @author Costin Manolache
@ -170,7 +170,7 @@ public abstract class LogFactory {
* <p>
* Construct (if necessary) and return a <code>Log</code> instance, using
* the factory's current set of configuration attributes.
*
* </p>
*
* <p>
* <strong>NOTE </strong>- Depending upon the implementation of the
@ -178,7 +178,7 @@ public abstract class LogFactory {
* you are returned may or may not be local to the current application, and
* may or may not be returned again on a subsequent call with the same name
* argument.
*
* </p>
*
* @param name
* Logical name of the <code>Log</code> instance to be
@ -229,7 +229,7 @@ public abstract class LogFactory {
* Construct (if necessary) and return a <code>LogFactory</code> instance,
* using the following ordered lookup procedure to determine the name of the
* implementation class to be loaded.
*
* </p>
* <ul>
* <li>The <code>org.apache.commons.logging.LogFactory</code> system
* property.</li>
@ -248,7 +248,7 @@ public abstract class LogFactory {
* <code>LogFactory</code> implementation class is utilized, all of the
* properties defined in this file will be set as configuration attributes on
* the corresponding <code>LogFactory</code> instance.
*
* </p>
*
* @exception LogConfigurationException
* if the implementation class is not available or cannot
@ -345,64 +345,64 @@ public abstract class LogFactory {
* This method exists to ensure signature compatibility.
*/
protected static Object createFactory(String factoryClass, ClassLoader classLoader) {
throw new UnsupportedOperationException(
"Operation [factoryClass] is not supported in jcl-over-slf4j. See also " + UNSUPPORTED_OPERATION_IN_JCL_OVER_SLF4J);
throw new UnsupportedOperationException("Operation [factoryClass] is not supported in jcl-over-slf4j. See also "
+ UNSUPPORTED_OPERATION_IN_JCL_OVER_SLF4J);
}
/**
* This method exists to ensure signature compatibility.
*/
protected static ClassLoader directGetContextClassLoader() {
throw new UnsupportedOperationException(
"Operation [directGetContextClassLoader] is not supported in jcl-over-slf4j. See also " + UNSUPPORTED_OPERATION_IN_JCL_OVER_SLF4J);
throw new UnsupportedOperationException("Operation [directGetContextClassLoader] is not supported in jcl-over-slf4j. See also "
+ UNSUPPORTED_OPERATION_IN_JCL_OVER_SLF4J);
}
/**
* This method exists to ensure signature compatibility.
*/
protected static ClassLoader getContextClassLoader() throws LogConfigurationException {
throw new UnsupportedOperationException(
"Operation [getContextClassLoader] is not supported in jcl-over-slf4j. See also " + UNSUPPORTED_OPERATION_IN_JCL_OVER_SLF4J);
throw new UnsupportedOperationException("Operation [getContextClassLoader] is not supported in jcl-over-slf4j. See also "
+ UNSUPPORTED_OPERATION_IN_JCL_OVER_SLF4J);
}
/**
* This method exists to ensure signature compatibility.
*/
protected static ClassLoader getClassLoader(Class clazz) {
throw new UnsupportedOperationException(
"Operation [getClassLoader] is not supported in jcl-over-slf4j. See also " + UNSUPPORTED_OPERATION_IN_JCL_OVER_SLF4J);
throw new UnsupportedOperationException("Operation [getClassLoader] is not supported in jcl-over-slf4j. See also "
+ UNSUPPORTED_OPERATION_IN_JCL_OVER_SLF4J);
}
/**
* This method exists to ensure signature compatibility.
*/
protected static boolean isDiagnosticsEnabled() {
throw new UnsupportedOperationException(
"Operation [isDiagnosticsEnabled] is not supported in jcl-over-slf4j. See also " + UNSUPPORTED_OPERATION_IN_JCL_OVER_SLF4J);
throw new UnsupportedOperationException("Operation [isDiagnosticsEnabled] is not supported in jcl-over-slf4j. See also "
+ UNSUPPORTED_OPERATION_IN_JCL_OVER_SLF4J);
}
/**
* This method exists to ensure signature compatibility.
*/
protected static void logRawDiagnostic(String msg) {
throw new UnsupportedOperationException(
"Operation [logRawDiagnostic] is not supported in jcl-over-slf4j. See also " + UNSUPPORTED_OPERATION_IN_JCL_OVER_SLF4J);
throw new UnsupportedOperationException("Operation [logRawDiagnostic] is not supported in jcl-over-slf4j. See also "
+ UNSUPPORTED_OPERATION_IN_JCL_OVER_SLF4J);
}
/**
* This method exists to ensure signature compatibility.
*/
protected static LogFactory newFactory(final String factoryClass, final ClassLoader classLoader, final ClassLoader contextClassLoader) {
throw new UnsupportedOperationException(
"Operation [logRawDiagnostic] is not supported in jcl-over-slf4j. See also " + UNSUPPORTED_OPERATION_IN_JCL_OVER_SLF4J);
throw new UnsupportedOperationException("Operation [logRawDiagnostic] is not supported in jcl-over-slf4j. See also "
+ UNSUPPORTED_OPERATION_IN_JCL_OVER_SLF4J);
}
/**
* This method exists to ensure signature compatibility.
*/
protected static LogFactory newFactory(final String factoryClass, final ClassLoader classLoader) {
throw new UnsupportedOperationException(
"Operation [newFactory] is not supported in jcl-over-slf4j. See also " + UNSUPPORTED_OPERATION_IN_JCL_OVER_SLF4J);
throw new UnsupportedOperationException("Operation [newFactory] is not supported in jcl-over-slf4j. See also "
+ UNSUPPORTED_OPERATION_IN_JCL_OVER_SLF4J);
}
}

View File

@ -23,7 +23,7 @@ import org.apache.commons.logging.Log;
* <p>
* Trivial implementation of Log that throws away all messages. No configurable
* system properties are supported.
*
* </p>
*
* @author <a href="mailto:sanders@apache.org">Scott Sanders</a>
* @author Rod Waldhoff

View File

@ -43,11 +43,11 @@ public class SLF4JLocationAwareLog implements Log, Serializable {
// in both Log4jLogger and Jdk14Logger classes in the original JCL, the
// logger instance is transient
private final transient LocationAwareLogger logger;
private transient LocationAwareLogger logger;
private static final String FQCN = SLF4JLocationAwareLog.class.getName();
public SLF4JLocationAwareLog(LocationAwareLogger logger) {
SLF4JLocationAwareLog(LocationAwareLogger logger) {
this.logger = logger;
this.name = logger.getName();
}

View File

@ -42,9 +42,9 @@ public class SLF4JLog implements Log, Serializable {
// in both Log4jLogger and Jdk14Logger classes in the original JCL, the
// logger instance is transient
private final transient Logger logger;
private transient Logger logger;
public SLF4JLog(Logger logger) {
SLF4JLog(Logger logger) {
this.logger = logger;
this.name = logger.getName();
}

View File

@ -42,7 +42,7 @@ import java.util.concurrent.ConcurrentMap;
*
* <p>
* This implementation ignores any configured attributes.
*
* </p>
*
* @author Rod Waldhoff
* @author Craig R. McClanahan
@ -64,7 +64,7 @@ public class SLF4JLogFactory extends LogFactory {
* Public no-arguments constructor required by the lookup mechanism.
*/
public SLF4JLogFactory() {
loggerMap = new ConcurrentHashMap<>();
loggerMap = new ConcurrentHashMap<String, Log>();
}
// ----------------------------------------------------- Manifest Constants
@ -105,12 +105,12 @@ public class SLF4JLogFactory extends LogFactory {
@SuppressWarnings("unchecked")
public String[] getAttributeNames() {
List<String> names = new ArrayList<>();
List<String> names = new ArrayList<String>();
Enumeration<String> keys = attributes.keys();
while (keys.hasMoreElements()) {
names.add((String) keys.nextElement());
}
String[] results = new String[names.size()];
String results[] = new String[names.size()];
for (int i = 0; i < results.length; i++) {
results[i] = (String) names.get(i);
}
@ -136,7 +136,7 @@ public class SLF4JLogFactory extends LogFactory {
* <p>
* Construct (if necessary) and return a <code>Log</code> instance, using
* the factory's current set of configuration attributes.
*
* </p>
*
* @param name
* Logical name of the <code>Log</code> instance to be returned
@ -173,10 +173,12 @@ public class SLF4JLogFactory extends LogFactory {
public void release() {
// This method is never called by jcl-over-slf4j classes. However,
// in certain deployment scenarios, in particular if jcl-over-slf4j.jar
// is in the web-app class loader and the official commons-logging.jar
// is deployed in some parent class loader (e.g. commons/lib), then it
// is possible for the parent class loader to mask the classes shipping
// in jcl-over-slf4j.jar.
// is
// in the the web-app class loader and the official commons-logging.jar is
// deployed in some parent class loader (e.g. commons/lib), then it is
// possible
// for the parent class loader to mask the classes shipping in
// jcl-over-slf4j.jar.
System.out.println("WARN: The method " + SLF4JLogFactory.class + "#release() was invoked.");
System.out.println("WARN: Please see http://www.slf4j.org/codes.html#release for an explanation.");
System.out.flush();
@ -214,4 +216,4 @@ public class SLF4JLogFactory extends LogFactory {
}
}
}
}

View File

@ -35,7 +35,7 @@ import org.apache.commons.logging.LogConfigurationException;
* Simple implementation of Log that sends all enabled log messages, for all
* defined loggers, to System.err. The following system properties are supported
* to configure the behavior of this logger:
*
* </p>
* <ul>
* <li><code>org.apache.commons.logging.simplelog.defaultlog</code> - Default
* logging detail level for all instances of SimpleLog. Must be one of ("trace",
@ -67,7 +67,7 @@ import org.apache.commons.logging.LogConfigurationException;
* this implementation also checks for a class loader resource named
* <code>"simplelog.properties"</code>, and includes any matching definitions
* from this resource (if it exists).
*
* </p>
*
* @author <a href="mailto:sanders@apache.org">Scott Sanders</a>
* @author Rod Waldhoff
@ -165,7 +165,7 @@ public class SimpleLog implements Log, Serializable {
} catch (java.io.IOException e) {
// ignored
}
}
}
}
showLogName = getBooleanProperty(systemPrefix + "showlogname", showLogName);
@ -248,7 +248,7 @@ public class SimpleLog implements Log, Serializable {
/**
* <p>
* Set logging level.
*
* </p>
*
* @param currentLogLevel
* new logging level
@ -262,7 +262,7 @@ public class SimpleLog implements Log, Serializable {
/**
* <p>
* Get logging level.
*
* </p>
*/
public int getLevel() {
@ -275,7 +275,7 @@ public class SimpleLog implements Log, Serializable {
* <p>
* Do the actual logging. This method assembles the message and then calls
* <code>write()</code> to cause it to be written.
*
* </p>
*
* @param type
* One of the LOG_LEVEL_XXX constants defining the log level
@ -354,7 +354,7 @@ public class SimpleLog implements Log, Serializable {
* Write the content of the message accumulated in the specified
* <code>StringBuffer</code> to the appropriate output destination. The
* default implementation writes to <code>System.err</code>.
*
* </p>
*
* @param buffer
* A <code>StringBuffer</code> containing the accumulated text to be
@ -383,7 +383,7 @@ public class SimpleLog implements Log, Serializable {
/**
* <p>
* Log a message with debug log level.
*
* </p>
*/
public final void debug(Object message) {
@ -395,7 +395,7 @@ public class SimpleLog implements Log, Serializable {
/**
* <p>
* Log an error with debug log level.
*
* </p>
*/
public final void debug(Object message, Throwable t) {
@ -407,7 +407,7 @@ public class SimpleLog implements Log, Serializable {
/**
* <p>
* Log a message with trace log level.
*
* </p>
*/
public final void trace(Object message) {
@ -419,7 +419,7 @@ public class SimpleLog implements Log, Serializable {
/**
* <p>
* Log an error with trace log level.
*
* </p>
*/
public final void trace(Object message, Throwable t) {
@ -431,7 +431,7 @@ public class SimpleLog implements Log, Serializable {
/**
* <p>
* Log a message with info log level.
*
* </p>
*/
public final void info(Object message) {
@ -443,7 +443,7 @@ public class SimpleLog implements Log, Serializable {
/**
* <p>
* Log an error with info log level.
*
* </p>
*/
public final void info(Object message, Throwable t) {
@ -455,7 +455,7 @@ public class SimpleLog implements Log, Serializable {
/**
* <p>
* Log a message with warn log level.
*
* </p>
*/
public final void warn(Object message) {
@ -467,7 +467,7 @@ public class SimpleLog implements Log, Serializable {
/**
* <p>
* Log an error with warn log level.
*
* </p>
*/
public final void warn(Object message, Throwable t) {
@ -479,7 +479,7 @@ public class SimpleLog implements Log, Serializable {
/**
* <p>
* Log a message with error log level.
*
* </p>
*/
public final void error(Object message) {
@ -491,7 +491,7 @@ public class SimpleLog implements Log, Serializable {
/**
* <p>
* Log an error with error log level.
*
* </p>
*/
public final void error(Object message, Throwable t) {
@ -503,7 +503,7 @@ public class SimpleLog implements Log, Serializable {
/**
* <p>
* Log a message with fatal log level.
*
* </p>
*/
public final void fatal(Object message) {
@ -515,7 +515,7 @@ public class SimpleLog implements Log, Serializable {
/**
* <p>
* Log an error with fatal log level.
*
* </p>
*/
public final void fatal(Object message, Throwable t) {
@ -527,12 +527,12 @@ public class SimpleLog implements Log, Serializable {
/**
* <p>
* Are debug messages currently enabled?
*
* </p>
*
* <p>
* This allows expensive operations such as <code>String</code> concatenation
* to be avoided when the message will be ignored by the logger.
*
* </p>
*/
public final boolean isDebugEnabled() {
@ -542,12 +542,12 @@ public class SimpleLog implements Log, Serializable {
/**
* <p>
* Are error messages currently enabled?
*
* </p>
*
* <p>
* This allows expensive operations such as <code>String</code> concatenation
* to be avoided when the message will be ignored by the logger.
*
* </p>
*/
public final boolean isErrorEnabled() {
@ -557,12 +557,12 @@ public class SimpleLog implements Log, Serializable {
/**
* <p>
* Are fatal messages currently enabled?
*
* </p>
*
* <p>
* This allows expensive operations such as <code>String</code> concatenation
* to be avoided when the message will be ignored by the logger.
*
* </p>
*/
public final boolean isFatalEnabled() {
@ -572,12 +572,12 @@ public class SimpleLog implements Log, Serializable {
/**
* <p>
* Are info messages currently enabled?
*
* </p>
*
* <p>
* This allows expensive operations such as <code>String</code> concatenation
* to be avoided when the message will be ignored by the logger.
*
* </p>
*/
public final boolean isInfoEnabled() {
@ -587,12 +587,12 @@ public class SimpleLog implements Log, Serializable {
/**
* <p>
* Are trace messages currently enabled?
*
* </p>
*
* <p>
* This allows expensive operations such as <code>String</code> concatenation
* to be avoided when the message will be ignored by the logger.
*
* </p>
*/
public final boolean isTraceEnabled() {
@ -602,12 +602,12 @@ public class SimpleLog implements Log, Serializable {
/**
* <p>
* Are warn messages currently enabled?
*
* </p>
*
* <p>
* This allows expensive operations such as <code>String</code> concatenation
* to be avoided when the message will be ignored by the logger.
*
* </p>
*/
public final boolean isWarnEnabled() {
@ -673,13 +673,15 @@ public class SimpleLog implements Log, Serializable {
}
private static InputStream getResourceAsStream(final String name) {
return AccessController.doPrivileged((PrivilegedAction<InputStream>) () -> {
ClassLoader threadCL = getContextClassLoader();
return AccessController.doPrivileged(new PrivilegedAction<InputStream>() {
public InputStream run() {
ClassLoader threadCL = getContextClassLoader();
if (threadCL != null) {
return threadCL.getResourceAsStream(name);
} else {
return ClassLoader.getSystemResourceAsStream(name);
if (threadCL != null) {
return threadCL.getResourceAsStream(name);
} else {
return ClassLoader.getSystemResourceAsStream(name);
}
}
});
}

View File

@ -31,7 +31,7 @@ replacement for the original JCL version 1.0.4.
<p>As the original JCL version 1.0.4, the present version supports
various logging APIs. It differs from the original in implementation
but not the public API. This implementation uses SLF4J under the
covers. As such, all the logging systems that SLF4J supports,
covers. As as such, all the logging systems that SLF4J supports,
e.g. NOP, Simple, JDK14, nlog4j are supported by this version of JCL.
</p>

View File

@ -1,4 +0,0 @@
module org.apache.commons.logging {
requires org.slf4j;
exports org.apache.commons.logging;
}

View File

@ -0,0 +1,10 @@
Implementation-Title: jcl-over-slf4j
Bundle-ManifestVersion: 2
Bundle-SymbolicName: jcl.over.slf4j
Bundle-Name: jcl-over-slf4j
Bundle-Vendor: SLF4J.ORG
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Automatic-Module-Name: org.apache.commons.logging
Export-Package: org.apache.commons.logging;version=1.2,
org.apache.commons.logging.impl;version=1.2
Import-Package: org.slf4j;version=${parsedVersion.osgiVersion}, org.slf4j.spi;version=${parsedVersion.osgiVersion}

View File

@ -23,15 +23,12 @@
*
*/
package org.apache.commons.logging.test;
package org.apache.commons.logging;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertEquals;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.Test;
public class InvokeJCLTest {
@ -132,9 +129,7 @@ public class InvokeJCLTest {
private final String msg;
int invokedCount = 0;
TestMessage(String msg) {
this.msg = msg;
}
TestMessage(String msg) {this.msg = msg;}
@Override
public String toString() {

View File

@ -22,7 +22,7 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
package org.apache.commons.logging.test;
package org.apache.commons.logging.impl;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@ -32,12 +32,10 @@ import java.io.ObjectOutputStream;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.commons.logging.impl.SLF4JLocationAwareLog;
import org.apache.commons.logging.impl.SLF4JLog;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.jul.JDK14LoggerFactory;
import org.slf4j.impl.JDK14LoggerFactory;
import org.slf4j.spi.LocationAwareLogger;
public class SerializationTest {

View File

@ -7,8 +7,7 @@
<parent>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-parent</artifactId>
<version>2.0.19-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
<version>1.7.33</version>
</parent>
<artifactId>jul-to-slf4j</artifactId>
@ -26,15 +25,10 @@
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-reload4j</artifactId>
<artifactId>slf4j-log4j12</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
</plugins>
</build>
</project>

View File

@ -39,12 +39,12 @@ import org.slf4j.spi.LocationAwareLogger;
// Based on http://jira.qos.ch/browse/SLF4J-30
/**
* <p>Bridge/route all JUL log records to the SLF4J API.
* <p>Bridge/route all JUL log records to the SLF4J API.</p>
* <p>Essentially, the idea is to install on the root logger an instance of
* <code>SLF4JBridgeHandler</code> as the sole JUL handler in the system. Subsequently, the
* SLF4JBridgeHandler instance will redirect all JUL log records are redirected
* to the SLF4J API based on the following mapping of levels:
*
* </p>
* <pre>
* FINEST -&gt; TRACE
* FINER -&gt; DEBUG
@ -52,7 +52,7 @@ import org.slf4j.spi.LocationAwareLogger;
* INFO -&gt; INFO
* WARNING -&gt; WARN
* SEVERE -&gt; ERROR</pre>
* <p><b>Programmatic installation:</b>
* <p><b>Programmatic installation:</b></p>
* <pre>
* // Optionally remove existing handlers attached to j.u.l root logger
* SLF4JBridgeHandler.removeHandlersForRootLogger(); // (since SLF4J 1.6.5)
@ -60,12 +60,12 @@ import org.slf4j.spi.LocationAwareLogger;
* // add SLF4JBridgeHandler to j.u.l's root logger, should be done once during
* // the initialization phase of your application
* SLF4JBridgeHandler.install();</pre>
* <p><b>Installation via <em>logging.properties</em> configuration file:</b>
* <p><b>Installation via <em>logging.properties</em> configuration file:</b></p>
* <pre>
* // register SLF4JBridgeHandler as handler for the j.u.l. root logger
* handlers = org.slf4j.bridge.SLF4JBridgeHandler</pre>
* <p>Once SLF4JBridgeHandler is installed, logging by j.u.l. loggers will be directed to
* SLF4J. Example:
* SLF4J. Example: </p>
* <pre>
* import java.util.logging.Logger;
* ...
@ -79,26 +79,17 @@ import org.slf4j.spi.LocationAwareLogger;
* SLF4J translation can seriously increase the cost of disabled logging
* statements (60 fold or 6000% increase) and measurably impact the performance of enabled log
* statements (20% overall increase).</b> Please note that as of logback-version 0.9.25,
* it is possible to completely eliminate the 60-fold translation overhead for disabled
* it is possible to completely eliminate the 60 fold translation overhead for disabled
* log statements with the help of <a href="http://logback.qos.ch/manual/configuration.html#LevelChangePropagator">LevelChangePropagator</a>.
*
* </p>
*
* <p>If you are concerned about application performance, then use of <code>SLF4JBridgeHandler</code>
* is appropriate only if any of the following conditions is true:
* is appropriate only if any one the following two conditions is true:</p>
* <ol>
* <li>few j.u.l. logging statements are in play</li>
* <li>LevelChangePropagator has been installed</li>
* </ol>
*
* <h2>As a Java 9/Jigsaw module</h2>
*
* <p>Given that <b>to</b> is a reserved keyword under Java 9 within module productions,
* the MANIFEST.MF file in <em>jul-to-slf4j.jar</em> declares <b>jul_to_slf4j</b> as
* its Automatic Module Name. Thus, if your application is Jigsaw modularized, the requires
* statement in your <em>module-info.java</em> needs to be <b>jul_to_slf4j</b>
* (note the two underscores).
*
*
* @author Christian Stein
* @author Joern Huxhorn
* @author Ceki G&uuml;lc&uuml;
@ -118,8 +109,9 @@ public class SLF4JBridgeHandler extends Handler {
/**
* Adds a SLF4JBridgeHandler instance to jul's root logger.
*
* <p>This handler will redirect j.u.l. logging to SLF4J. However, only logs enabled
* <p/>
* <p/>
* This handler will redirect j.u.l. logging to SLF4J. However, only logs enabled
* in j.u.l. will be redirected. For example, if a log statement invoking a
* j.u.l. logger is disabled, then the corresponding non-event will <em>not</em>
* reach SLF4JBridgeHandler and cannot be redirected.
@ -143,9 +135,9 @@ public class SLF4JBridgeHandler extends Handler {
public static void uninstall() throws SecurityException {
java.util.logging.Logger rootLogger = getRootLogger();
Handler[] handlers = rootLogger.getHandlers();
for (Handler handler : handlers) {
if (handler instanceof SLF4JBridgeHandler) {
rootLogger.removeHandler(handler);
for (int i = 0; i < handlers.length; i++) {
if (handlers[i] instanceof SLF4JBridgeHandler) {
rootLogger.removeHandler(handlers[i]);
}
}
}
@ -153,14 +145,14 @@ public class SLF4JBridgeHandler extends Handler {
/**
* Returns true if SLF4JBridgeHandler has been previously installed, returns false otherwise.
*
* @return true if SLF4JBridgeHandler is already installed, false otherwise
*
* @return true if SLF4JBridgeHandler is already installed, false other wise
* @throws SecurityException
*/
public static boolean isInstalled() {
public static boolean isInstalled() throws SecurityException {
java.util.logging.Logger rootLogger = getRootLogger();
Handler[] handlers = rootLogger.getHandlers();
for (Handler handler : handlers) {
if (handler instanceof SLF4JBridgeHandler) {
for (int i = 0; i < handlers.length; i++) {
if (handlers[i] instanceof SLF4JBridgeHandler) {
return true;
}
}
@ -174,8 +166,8 @@ public class SLF4JBridgeHandler extends Handler {
public static void removeHandlersForRootLogger() {
java.util.logging.Logger rootLogger = getRootLogger();
java.util.logging.Handler[] handlers = rootLogger.getHandlers();
for (Handler handler : handlers) {
rootLogger.removeHandler(handler);
for (int i = 0; i < handlers.length; i++) {
rootLogger.removeHandler(handlers[i]);
}
}
@ -201,9 +193,6 @@ public class SLF4JBridgeHandler extends Handler {
/**
* Return the Logger instance that will be used for logging.
*
* @param record a LogRecord
* @return an SLF4J logger corresponding to the record parameter's logger name
*/
protected Logger getSLF4JLogger(LogRecord record) {
String name = record.getLoggerName();
@ -285,10 +274,10 @@ public class SLF4JBridgeHandler extends Handler {
/**
* Publish a LogRecord.
* <p>
* <p/>
* The logging request was made initially to a Logger object, which
* initialized the LogRecord and forwarded it here.
* <p>
* <p/>
* This handler ignores the Level attached to the LogRecord, as SLF4J cares
* about discarding log statements.
*
@ -302,12 +291,13 @@ public class SLF4JBridgeHandler extends Handler {
}
Logger slf4jLogger = getSLF4JLogger(record);
String message = record.getMessage(); // can be null!
// this is a check to avoid calling the underlying logging system
// with a null message. While it is legitimate to invoke j.u.l. with
// a null message, other logging frameworks do not support this.
// see also http://jira.qos.ch/browse/SLF4J-99
if (record.getMessage() == null) {
record.setMessage("");
if (message == null) {
message = "";
}
if (slf4jLogger instanceof LocationAwareLogger) {
callLocationAwareLogger((LocationAwareLogger) slf4jLogger, record);

View File

@ -10,6 +10,6 @@
<p>Bridge/route all JUL log records to the SLF4J API.</p>
<hr>
<hr/>
</body>
</html>

View File

@ -1,7 +0,0 @@
module jul.to.slf4j {
requires org.slf4j;
requires java.logging;
exports org.slf4j.bridge;
}

View File

@ -0,0 +1,7 @@
Bundle-ManifestVersion: 2
Bundle-SymbolicName: jul.to.slf4j
Bundle-Name: jul-to-slf4j
Bundle-Vendor: SLF4J.ORG
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Export-Package: org.slf4j.bridge;version=${parsedVersion.osgiVersion};uses:="org.slf4j,org.slf4j.spi"
Import-Package: org.slf4j;version=${parsedVersion.osgiVersion},org.slf4j.spi;version=${parsedVersion.osgiVersion}

View File

@ -32,7 +32,7 @@ import org.apache.log4j.spi.LoggingEvent;
public class ListAppender extends AppenderSkeleton {
public List<LoggingEvent> list = new ArrayList<>();
public List<LoggingEvent> list = new ArrayList<LoggingEvent>();
public boolean extractLocationInfo = false;

View File

@ -56,8 +56,8 @@ public class SLF4JBridgeHandlerPerfTest {
fileAppender = new FileAppender(new PatternLayout("%r [%t] %p %c %x - %m%n"), "target/test-output/toto.log");
existingHandlers = julRootLogger.getHandlers();
for (Handler existingHandler : existingHandlers) {
julRootLogger.removeHandler(existingHandler);
for (int i = 0; i < existingHandlers.length; i++) {
julRootLogger.removeHandler(existingHandlers[i]);
}
log4jRoot = org.apache.log4j.Logger.getRootLogger();
log4jRoot.addAppender(fileAppender);
@ -68,8 +68,8 @@ public class SLF4JBridgeHandlerPerfTest {
SLF4JBridgeHandler.uninstall();
fileAppender.close();
log4jRoot.getLoggerRepository().resetConfiguration();
for (Handler existingHandler : existingHandlers) {
julRootLogger.addHandler(existingHandler);
for (int i = 0; i < existingHandlers.length; i++) {
julRootLogger.addHandler(existingHandlers[i]);
}
}

View File

@ -42,16 +42,14 @@ public class SLF4JBridgeHandlerTest {
ListAppender listAppender = new ListAppender();
org.apache.log4j.Logger log4jRoot;
java.util.logging.Logger julLogger = java.util.logging.Logger.getLogger(LOGGER_NAME);
java.util.logging.Logger julRootLogger = java.util.logging.Logger.getLogger("");
java.util.logging.Logger julLogger = java.util.logging.Logger.getLogger("yay");
@Before
public void setUp() throws Exception {
listAppender.extractLocationInfo = true;
log4jRoot = org.apache.log4j.Logger.getRootLogger();
log4jRoot.addAppender(listAppender);
log4jRoot.setLevel(org.apache.log4j.Level.TRACE);
julRootLogger.setLevel(Level.FINEST);
}
@After
@ -63,7 +61,6 @@ public class SLF4JBridgeHandlerTest {
@Test
public void testSmoke() {
SLF4JBridgeHandler.install();
String msg = "msg";
julLogger.info(msg);
assertEquals(1, listAppender.list.size());
@ -80,19 +77,6 @@ public class SLF4JBridgeHandlerTest {
assertEquals("SLF4JBridgeHandlerTest.java", li.getFileName());
assertEquals("testSmoke", li.getMethodName());
}
@Test
public void LOGBACK_1612() {
SLF4JBridgeHandler.install();
String msg = "LOGBACK_1612";
julLogger.finer(msg);
assertEquals(1, listAppender.list.size());
LoggingEvent le = (LoggingEvent) listAppender.list.get(0);
assertEquals(LOGGER_NAME, le.getLoggerName());
assertEquals(msg, le.getMessage());
}
@Test
public void testLevels() {
@ -117,8 +101,6 @@ public class SLF4JBridgeHandlerTest {
assertLevel(i++, org.apache.log4j.Level.ERROR);
}
@Test
public void testLogWithResourceBundle() {
SLF4JBridgeHandler.install();
@ -133,7 +115,7 @@ public class SLF4JBridgeHandlerTest {
julResourceBundleLogger.info(msg);
assertEquals(1, listAppender.list.size());
LoggingEvent le = listAppender.list.get(0);
LoggingEvent le = (LoggingEvent) listAppender.list.get(0);
assertEquals(LOGGER_NAME, le.getLoggerName());
assertEquals(expectedMsg, le.getMessage());
}
@ -167,19 +149,19 @@ public class SLF4JBridgeHandlerTest {
LoggingEvent le = null;
le = listAppender.list.get(0);
le = (LoggingEvent) listAppender.list.get(0);
assertEquals("foo", le.getLoggerName());
assertEquals(expectedMsg1, le.getMessage());
le = listAppender.list.get(1);
le = (LoggingEvent) listAppender.list.get(1);
assertEquals("foo", le.getLoggerName());
assertEquals(expectedMsg2, le.getMessage());
le = listAppender.list.get(2);
le = (LoggingEvent) listAppender.list.get(2);
assertEquals("foo", le.getLoggerName());
assertEquals(expectedMsg3, le.getMessage());
le = listAppender.list.get(3);
le = (LoggingEvent) listAppender.list.get(3);
assertEquals("yay", le.getLoggerName());
assertEquals(expectedMsg3, le.getMessage());
}
@ -191,7 +173,7 @@ public class SLF4JBridgeHandlerTest {
julLogger.logp(Level.INFO, "SLF4JBridgeHandlerTest", "testLogWithPlaceholderNoParameters", msg, new Object[0]);
assertEquals(1, listAppender.list.size());
LoggingEvent le = listAppender.list.get(0);
LoggingEvent le = (LoggingEvent) listAppender.list.get(0);
assertEquals(LOGGER_NAME, le.getLoggerName());
assertEquals(msg, le.getMessage());
}
@ -205,22 +187,12 @@ public class SLF4JBridgeHandlerTest {
julLogger.log(Level.INFO, msg, "ignored parameter due to IllegalArgumentException");
assertEquals(1, listAppender.list.size());
LoggingEvent le = listAppender.list.get(0);
LoggingEvent le = (LoggingEvent) listAppender.list.get(0);
assertEquals(msg, le.getMessage());
}
@Test
public void withNullMessage() {
SLF4JBridgeHandler.install();
String msg = null;
julLogger.log(Level.INFO, msg);
assertEquals(1, listAppender.list.size());
LoggingEvent le = listAppender.list.get(0);
assertEquals("", le.getMessage());
}
void assertLevel(int index, org.apache.log4j.Level expectedLevel) {
LoggingEvent le = listAppender.list.get(index);
LoggingEvent le = (LoggingEvent) listAppender.list.get(index);
assertEquals(expectedLevel, le.getLevel());
}
}

View File

@ -1,176 +0,0 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS

View File

@ -0,0 +1,137 @@
<project name="testing-log4j-bridge" default="usage" basedir=".">
<property name="lbversion" value="0.9.8-SNAPSHOT" />
<property name="slf4jversion" value="1.4.2" />
<property name="source.home" value="./src/main/java/" />
<property name="javac.dest.12" value="./target/classes12/" />
<property name="javac.dest.13" value="./target/classes13/" />
<property name="lib" value="./lib" />
<property name="deprecation" value="on" />
<path id="basic.classpath">
<pathelement location="${source.home}" />
<pathelement location="${lib}/junit-3.8.1.jar" />
</path>
<path id="log4j12.classpath">
<path refid="basic.classpath" />
<pathelement location="${javac.dest.12}" />
<pathelement location="${lib}/log4j-1.2.14.jar" />
</path>
<path id="log4j13.classpath">
<path refid="basic.classpath" />
<pathelement location="${javac.dest.13}" />
<pathelement location="${lib}/log4j-1.3alpha-8.jar" />
</path>
<path id="los.classpath">
<path refid="basic.classpath" />
<pathelement location="${lib}/log4j-over-slf4j-${slf4jversion}.jar" />
<pathelement location="${lib}/logback-classic-${lbversion}.jar" />
<pathelement location="${lib}/logback-core-${lbversion}.jar" />
<pathelement location="${lib}/slf4j-api-${slf4jversion}.jar" />
</path>
<!-- ================================================================= -->
<!-- Default target -->
<!-- ================================================================= -->
<target name="usage">
<echo>
These are some of the targets supported by this ANT build scpript:
all - run all available tests
refresh - copy required jar files to the lib directory
</echo>
</target>
<delete>
<fileset dir="." includes="**/*.bak"/>
</delete>
<target name="refresh">
<delete>
<fileset dir="lib">
<include name="logback-*.jar"/>
<include name="log4j-bridge-*.jar"/>
</fileset>
</delete>
<copy file="../../slf4j-api/target/slf4j-api-${slf4jversion}.jar" todir="lib/"/>
<copy file="../target/log4j-over-slf4j-${slf4jversion}.jar" todir="lib/"/>
</target>
<target name="init">
<mkdir dir="${javac.dest.12}" />
<mkdir dir="${javac.dest.13}" />
</target>
<target name="clean">
<delete>
<fileset dir="${javac.dest.12}" includes="**" />
<fileset dir="${javac.dest.13}" includes="**" />
</delete>
</target>
<target name="build_log4j12" depends="init">
<javac srcdir="${source.home}"
destdir="${javac.dest.12}"
includes="**/Log4j12Calls.java"
deprecation="${deprecation}" debug="on">
<classpath refid="log4j12.classpath" />
</javac>
</target>
<target name="build_log4j13" depends="init">
<javac srcdir="${source.home}"
destdir="${javac.dest.13}"
includes="**/Log4j13Calls.java" deprecation="${deprecation}" debug="on">
<classpath refid="log4j13.classpath" />
</javac>
</target>
<target name="build_loggerTest" depends="init">
<javac srcdir="${source.home}"
destdir="${javac.dest.12}"
includes="**/LoggerTest.java"
deprecation="${deprecation}" debug="on">
<classpath refid="los.classpath" />
</javac>
</target>
<!-- ================================================================= -->
<!-- Run tests -->
<!-- ================================================================= -->
<target name="all" depends="test12, test13, loggerTest" />
<target name="loggerTest" depends="build_loggerTest">
<junit printsummary="yes" fork="yes" haltonfailure="yes">
<classpath refid="los.classpath" />
<classpath location="${javac.dest.12}" />
<formatter type="plain" usefile="false" />
<test name="test.LoggerTest" />
</junit>
</target>
<target name="test12" depends="build_log4j12">
<junit printsummary="yes" fork="yes" haltonfailure="yes">
<classpath refid="los.classpath" />
<classpath location="${javac.dest.12}" />
<formatter type="plain" usefile="false" />
<test name="test.Log4j12Calls" />
</junit>
</target>
<target name="test13" depends="build_log4j13">
<junit printsummary="yes" fork="yes" haltonfailure="yes">
<classpath refid="los.classpath" />
<classpath location="${javac.dest.13}" />
<formatter type="plain" usefile="false" />
<test name="test.Log4j13Calls" />
</junit>
</target>
</project>

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,17 @@
This directory is used to test the module against various log4j calls.
Two test cases simulate the typical calls that one can find in an application
that uses either log4j 1.2.x, or log4j 1.3.x.
In the same directory is a build.xml file that uses ant to
compile the test cases with the corresponding log4j version,
and to runs these tests without log4j in the classpath but with
logback jars instead.
To run the tests, one must have ant installed. Issuing the following command,
once in the compatibility directory will launch the tests:
ant all
To obtain more information about the use of the log4j-over-slf4j module,
please visit http://www..slf4j.org/log4j-over-slf4j.html

View File

@ -0,0 +1,8 @@
package test;
public class DummyObject {
public String toString() {
return "dummy";
}
}

View File

@ -0,0 +1,39 @@
/**
* Logback: the reliable, generic, fast and flexible logging framework.
*
* Copyright (C) 1999-2006, QOS.ch
*
* This library is free software, you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation.
*/
package test;
import junit.framework.TestCase;
import org.apache.log4j.Logger;
import org.apache.log4j.MDC;
/**
*
* A test case that issues the typical calls
* that an application using log4j 1.2 would do.
*
* @author Ceki G&uuml;lc&uuml;
* @author S&eacute;bastien Pennec
*/
public class Log4j12Calls extends TestCase {
public static final Logger logger = Logger.getLogger(Log4j12Calls.class);
public void testLog() {
MDC.put("key", "value1");
logger.trace("Trace level can be noisy");
logger.debug("Entering application");
logger.info("Violets are blue");
logger.warn("Here is a warning");
logger.error("Exiting application", new Exception("just testing"));
MDC.remove("key");
}
}

View File

@ -0,0 +1,46 @@
/**
* Logback: the reliable, generic, fast and flexible logging framework.
*
* Copyright (C) 1999-2006, QOS.ch
*
* This library is free software, you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation.
*/
package test;
import junit.framework.TestCase;
import org.apache.log4j.Logger;
import org.apache.log4j.MDC;
/**
*
* A test case that issues the typical calls
* that an application using log4j 1.3 would do.
*
* @author Ceki G&uuml;lc&uuml;
* @author S&eacute;bastien Pennec
*/
public class Log4j13Calls extends TestCase {
public static final Logger logger = Logger.getLogger(Log4j12Calls.class);
public void testLog() {
MDC.put("key", "value1");
logger.trace("Trace level can be noisy");
logger.debug("Entering application");
logger.info("Violets are blue");
logger.warn("Here is a warning");
logger.info("The answer is {}.", new Integer(42));
logger.info("Number: {} and another one: {}.", new Integer(42), new Integer(24));
logger.error("Exiting application", new Exception("just testing"));
MDC.remove("key");
MDC.clear();
}
}

View File

@ -0,0 +1,169 @@
package test;
import junit.framework.TestCase;
import org.slf4j.LoggerFactory;
import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.spi.LoggingEvent;
import ch.qos.logback.core.read.ListAppender;
import org.apache.log4j.Level;
/**
* A class that tests the invocation of the org.apache.log4j.Logger class that
* belongs to the log4j-bridge package
*
* @author S&eacute;bastien Pennec
* @author Ceki G&uuml;lc&uuml;
*/
public class LoggerTest extends TestCase {
LoggerContext context;
ListAppender<LoggingEvent> appender;
ch.qos.logback.classic.Logger logbackLogger;
org.apache.log4j.Logger log4jLogger;
public void setUp() throws Exception {
context = (LoggerContext) LoggerFactory.getILoggerFactory();
context.shutdownAndReset();
appender = new ListAppender<LoggingEvent>();
appender.setContext(context);
appender.setName("listAppender");
appender.start();
ch.qos.logback.classic.Logger lbLogger = context
.getLogger(LoggerContext.ROOT_NAME);
lbLogger.addAppender(appender);
log4jLogger = org.apache.log4j.Logger.getLogger(LoggerTest.class);
logbackLogger = context.getLogger(LoggerTest.class);
super.setUp();
}
public void tearDown() throws Exception {
appender.stop();
context.stop();
appender = null;
context = null;
logbackLogger = null;
log4jLogger = null;
super.tearDown();
}
public void testLogWithObjectMessages() {
LoggingEvent event;
log4jLogger.debug("test");
event = appender.list.get(0);
assertEquals("test", event.getMessage());
appender.list.clear();
log4jLogger.debug(null);
event = appender.list.get(0);
assertEquals(null, event.getMessage());
appender.list.clear();
DummyObject dummy = new DummyObject();
log4jLogger.debug(dummy);
event = appender.list.get(0);
assertEquals(dummy.toString(), event.getMessage());
appender.list.clear();
}
public void testIsEnabledAPI() {
assertFalse(log4jLogger.isTraceEnabled());
assertTrue(log4jLogger.isDebugEnabled());
assertTrue(log4jLogger.isInfoEnabled());
assertTrue(log4jLogger.isWarnEnabled());
assertTrue(log4jLogger.isErrorEnabled());
}
public void testPrintAPI() {
Exception e = new Exception("just testing");
log4jLogger.trace(null);
assertEquals(1, appender.list.size());
appender.list.clear();
log4jLogger.debug(null);
assertEquals(1, appender.list.size());
appender.list.clear();
log4jLogger.debug("debug message");
assertEquals(1, appender.list.size());
appender.list.clear();
log4jLogger.info(null);
assertEquals(1, appender.list.size());
appender.list.clear();
log4jLogger.info("info message");
assertEquals(1, appender.list.size());
appender.list.clear();
log4jLogger.warn(null);
assertEquals(1, appender.list.size());
appender.list.clear();
log4jLogger.warn("warn message");
assertEquals(1, appender.list.size());
appender.list.clear();
log4jLogger.error(null);
assertEquals(1, appender.list.size());
appender.list.clear();
log4jLogger.error("error message");
assertEquals(1, appender.list.size());
appender.list.clear();
log4jLogger.debug(null, e);
assertEquals(1, appender.list.size());
appender.list.clear();
log4jLogger.debug("debug message", e);
assertEquals(1, appender.list.size());
appender.list.clear();
log4jLogger.info(null, e);
assertEquals(1, appender.list.size());
appender.list.clear();
log4jLogger.info("info message", e);
assertEquals(1, appender.list.size());
appender.list.clear();
log4jLogger.warn(null, e);
assertEquals(1, appender.list.size());
appender.list.clear();
log4jLogger.warn("warn message", e);
assertEquals(1, appender.list.size());
appender.list.clear();
log4jLogger.error(null, e);
assertEquals(1, appender.list.size());
appender.list.clear();
log4jLogger.error("error message", e);
assertEquals(1, appender.list.size());
appender.list.clear();
}
public void testLogAPI() {
log4jLogger.log("x", Level.TRACE, "x", null);
assertEquals(0, appender.list.size());
log4jLogger.log("x", Level.DEBUG, "x", null);
log4jLogger.log("x", Level.INFO, "x", null);
log4jLogger.log("x", Level.WARN, "x", null);
log4jLogger.log("x", Level.ERROR, "x", null);
log4jLogger.log("x", Level.FATAL, "x", null);
assertEquals(5, appender.list.size());
appender.list.clear();
}
}

View File

@ -7,8 +7,7 @@
<parent>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-parent</artifactId>
<version>2.0.19-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
<version>1.7.33</version>
</parent>
@ -21,15 +20,11 @@
<licenses>
<license>
<name>Apache-2.0</name>
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
<name>Apache Software Licenses</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
</license>
</licenses>
<properties>
<module-name>log4j</module-name>
</properties>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
@ -41,21 +36,5 @@
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<configuration>
<instructions>
<_exportcontents>org.apache.log4j*;version=${reload4j.version};-noimport:=true</_exportcontents>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -54,7 +54,7 @@ public interface Appender {
/**
* Release any resources allocated within the appender such as file
* handles, network connections, etc.
*
* <p/>
* <p>It is a programming error to append to a closed appender.
*
* @since 0.8.4
@ -114,12 +114,12 @@ public interface Appender {
* Configurators call this method to determine if the appender
* requires a layout. If this method returns <code>true</code>,
* meaning that layout is required, then the configurator will
* configure a layout using the configuration information at its
* configure an layout using the configuration information at its
* disposal. If this method returns <code>false</code>, meaning that
* a layout is not required, then layout configuration will be
* skipped even if there is available layout configuration
* information at the disposal of the configurator.
*
* <p/>
* <p>In the rather exceptional case, where the appender
* implementation admits a layout but can also work without it, then
* the appender should return <code>true</code>.

View File

@ -29,7 +29,7 @@ import java.util.Enumeration;
* This class is a minimal implementation of the original
* <code>org.apache.log4j.Category</code> class (as found in log4j 1.2) by
* delegation of all calls to a {@link org.slf4j.Logger} instance.
*
* </p>
*
* <p>
* Log4j's <code>trace</code>, <code>debug()</code>, <code>info()</code>,
@ -45,12 +45,12 @@ public class Category {
private static final String CATEGORY_FQCN = Category.class.getName();
private final String name;
private String name;
protected org.slf4j.Logger slf4jLogger;
private org.slf4j.spi.LocationAwareLogger locationAwareLogger;
private static final Marker FATAL_MARKER = MarkerFactory.getMarker("FATAL");
private static Marker FATAL_MARKER = MarkerFactory.getMarker("FATAL");
Category(String name) {
this.name = name;
@ -125,7 +125,6 @@ public class Category {
/**
* @deprecated Please use {@link #getLevel} instead.
* @return a Level
*/
final public Level getPriority() {
return null;
@ -133,9 +132,6 @@ public class Category {
/**
* Delegates to {@link org.slf4j.Logger#isDebugEnabled} method in SLF4J
*
* @return true if this logger is enabled for the level DEBUG
*
*/
public boolean isDebugEnabled() {
return slf4jLogger.isDebugEnabled();
@ -143,8 +139,6 @@ public class Category {
/**
* Delegates to {@link org.slf4j.Logger#isInfoEnabled} method in SLF4J
*
* @return true if this logger is enabled for the level INFO
*/
public boolean isInfoEnabled() {
return slf4jLogger.isInfoEnabled();
@ -152,8 +146,6 @@ public class Category {
/**
* Delegates to {@link org.slf4j.Logger#isWarnEnabled} method in SLF4J
*
* @return true if this logger is enabled for the level WARN
*/
public boolean isWarnEnabled() {
return slf4jLogger.isWarnEnabled();
@ -161,8 +153,6 @@ public class Category {
/**
* Delegates to {@link org.slf4j.Logger#isErrorEnabled} method in SLF4J
*
* @return true if this logger is enabled for the level ERROR
*/
public boolean isErrorEnabled() {
return slf4jLogger.isErrorEnabled();
@ -170,11 +160,13 @@ public class Category {
/**
* Determines whether the priority passed as parameter is enabled in the
* underlying SLF4J logger. Each log4j priority is mapped directly to its SLF4J
* equivalent, except for FATAL which is mapped as ERROR.
* underlying SLF4J logger. Each log4j priority is mapped directly to its
* SLF4J equivalent, except for FATAL which is mapped as ERROR.
*
* @param p the priority to check against
* @return true if this logger is enabled for the given level, false otherwise.
* @param p
* the priority to check against
* @return true if this logger is enabled for the given level, false
* otherwise.
*/
public boolean isEnabledFor(Priority p) {
switch (p.level) {
@ -202,19 +194,19 @@ public class Category {
} else {
switch (level) {
case LocationAwareLogger.TRACE_INT:
slf4jLogger.trace(marker, m, (Throwable) t);
slf4jLogger.trace(marker, m);
break;
case LocationAwareLogger.DEBUG_INT:
slf4jLogger.debug(marker, m, (Throwable) t);
slf4jLogger.debug(marker, m);
break;
case LocationAwareLogger.INFO_INT:
slf4jLogger.info(marker, m, (Throwable) t);
slf4jLogger.info(marker, m);
break;
case LocationAwareLogger.WARN_INT:
slf4jLogger.warn(marker, m, (Throwable) t);
slf4jLogger.warn(marker, m);
break;
case LocationAwareLogger.ERROR_INT:
slf4jLogger.error(marker, m, (Throwable) t);
slf4jLogger.error(marker, m);
break;
}
}
@ -222,8 +214,6 @@ public class Category {
/**
* Delegates to {@link org.slf4j.Logger#debug(String)} method of SLF4J.
*
* @param message a message to log
*/
public void debug(Object message) {
differentiatedLog(null, CATEGORY_FQCN, LocationAwareLogger.DEBUG_INT, message, null);
@ -232,9 +222,6 @@ public class Category {
/**
* Delegates to {@link org.slf4j.Logger#debug(String,Throwable)} method in
* SLF4J.
*
* @param message a message to log
* @param t a throwable to log
*/
public void debug(Object message, Throwable t) {
differentiatedLog(null, CATEGORY_FQCN, LocationAwareLogger.DEBUG_INT, message, t);
@ -242,18 +229,14 @@ public class Category {
/**
* Delegates to {@link org.slf4j.Logger#info(String)} method in SLF4J.
*
* @param message a message to log
*/
public void info(Object message) {
differentiatedLog(null, CATEGORY_FQCN, LocationAwareLogger.INFO_INT, message, null);
}
/**
* Delegates to {@link org.slf4j.Logger#info(String,Throwable)} method in SLF4J.
*
* @param message a message to log
* @param t a throwable to log
* Delegates to {@link org.slf4j.Logger#info(String,Throwable)} method in
* SLF4J.
*/
public void info(Object message, Throwable t) {
differentiatedLog(null, CATEGORY_FQCN, LocationAwareLogger.INFO_INT, message, t);
@ -261,20 +244,14 @@ public class Category {
/**
* Delegates to {@link org.slf4j.Logger#warn(String)} method in SLF4J.
*
* @param message a message to log
*
*/
public void warn(Object message) {
differentiatedLog(null, CATEGORY_FQCN, LocationAwareLogger.WARN_INT, message, null);
}
/**
* Delegates to {@link org.slf4j.Logger#warn(String,Throwable)} method in SLF4J.
*
* @param message a message to log
* @param t a throwable to log
*
* Delegates to {@link org.slf4j.Logger#warn(String,Throwable)} method in
* SLF4J.
*/
public void warn(Object message, Throwable t) {
differentiatedLog(null, CATEGORY_FQCN, LocationAwareLogger.WARN_INT, message, t);
@ -282,9 +259,6 @@ public class Category {
/**
* Delegates to {@link org.slf4j.Logger#error(String)} method in SLF4J.
*
* @param message a message to log
*
*/
public void error(Object message) {
differentiatedLog(null, CATEGORY_FQCN, LocationAwareLogger.ERROR_INT, message, null);
@ -293,10 +267,6 @@ public class Category {
/**
* Delegates to {@link org.slf4j.Logger#error(String,Throwable)} method in
* SLF4J.
*
* @param message a message to log
* @param t a throwable to log
*
*/
public void error(Object message, Throwable t) {
differentiatedLog(null, CATEGORY_FQCN, LocationAwareLogger.ERROR_INT, message, t);
@ -304,9 +274,6 @@ public class Category {
/**
* Delegates to {@link org.slf4j.Logger#error(String)} method in SLF4J.
*
* @param message a message to log
*
*/
public void fatal(Object message) {
differentiatedLog(FATAL_MARKER, CATEGORY_FQCN, LocationAwareLogger.ERROR_INT, message, null);
@ -315,10 +282,6 @@ public class Category {
/**
* Delegates to {@link org.slf4j.Logger#error(String,Throwable)} method in
* SLF4J. In addition, the call is marked with a marker named "FATAL".
*
* @param message a message to log
* @param t a throwable to log
*
*/
public void fatal(Object message, Throwable t) {
differentiatedLog(FATAL_MARKER, CATEGORY_FQCN, LocationAwareLogger.ERROR_INT, message, t);

View File

@ -20,7 +20,7 @@ package org.apache.log4j;
/**
* This class is a minimal implementation of the original Log4J class.
*
* @author Christian Trutz
* @author Christian Trutz <christian.trutz@belaso.de>
* */
public class Layout {

View File

@ -26,21 +26,21 @@ import java.io.ObjectStreamException;
import java.io.Serializable;
/**
* Defines the minimum set of levels recognized by the system, that is
* <code>OFF</code>, <code>FATAL</code>, <code>ERROR</code>, <code>WARN</code>,
* <code>INFO</code>, <code>DEBUG</code> and <code>ALL</code>.
*
* <p>
* The <code>Level</code> class may be subclassed to define a larger level set.
*
* @author Ceki G&uuml;lc&uuml;
*
Defines the minimum set of levels recognized by the system, that is
<code>OFF</code>, <code>FATAL</code>, <code>ERROR</code>,
<code>WARN</code>, <code>INFO</code>, <code>DEBUG</code> and
<code>ALL</code>.
<p>The <code>Level</code> class may be subclassed to define a larger
level set.
@author Ceki G&uuml;lc&uuml;
*/
public class Level extends Priority implements Serializable {
/**
* TRACE level integer value.
*
* @since 1.2.12
*/
public static final int TRACE_INT = 5000;
@ -49,52 +49,48 @@ public class Level extends Priority implements Serializable {
public static final int X_TRACE_INT = DEBUG_INT - 100;
/**
* The <code>OFF</code> has the highest possible rank and is intended to turn
* off logging.
*/
The <code>OFF</code> has the highest possible rank and is
intended to turn off logging. */
final static public Level OFF = new Level(OFF_INT, "OFF", 0);
/**
* The <code>FATAL</code> level designates very severe error events that will
* presumably lead the application to abort.
The <code>FATAL</code> level designates very severe error
events that will presumably lead the application to abort.
*/
final static public Level FATAL = new Level(FATAL_INT, "FATAL", 0);
/**
* The <code>ERROR</code> level designates error events that might still allow
* the application to continue running.
*/
The <code>ERROR</code> level designates error events that
might still allow the application to continue running. */
final static public Level ERROR = new Level(ERROR_INT, "ERROR", 3);
/**
* The <code>WARN</code> level designates potentially harmful situations.
*/
The <code>WARN</code> level designates potentially harmful situations.
*/
final static public Level WARN = new Level(WARN_INT, "WARN", 4);
/**
* The <code>INFO</code> level designates informational messages that highlight
* the progress of the application at coarse-grained level.
*/
The <code>INFO</code> level designates informational messages
that highlight the progress of the application at coarse-grained
level. */
final static public Level INFO = new Level(INFO_INT, "INFO", 6);
/**
* The <code>DEBUG</code> Level designates fine-grained informational events
* that are most useful to debug an application.
*/
The <code>DEBUG</code> Level designates fine-grained
informational events that are most useful to debug an
application. */
final static public Level DEBUG = new Level(DEBUG_INT, "DEBUG", 7);
/**
* The <code>TRACE</code> Level designates finer-grained informational events
* than the <code>DEBUG</code> level.
*
* @since 1.2.12
*/
* The <code>TRACE</code> Level designates finer-grained
* informational events than the <code>DEBUG</code level.
* @since 1.2.12
*/
public static final Level TRACE = new Level(TRACE_INT, "TRACE", 7);
/**
* The <code>ALL</code> has the lowest possible rank and is intended to turn on
* all logging.
*/
The <code>ALL</code> has the lowest possible rank and is intended to
turn on all logging. */
final static public Level ALL = new Level(ALL_INT, "ALL", 7);
/**
@ -103,47 +99,33 @@ public class Level extends Priority implements Serializable {
static final long serialVersionUID = 3491141966387921974L;
/**
* Instantiate a Level object.
*
* @param level a level
* @param levelStr a level string
* @param syslogEquivalent the Syslog equivalent
Instantiate a Level object.
*/
protected Level(int level, String levelStr, int syslogEquivalent) {
super(level, levelStr, syslogEquivalent);
}
/**
* Convert the string passed as argument to a level. If the conversion fails,
* then this method returns {@link #DEBUG}.
*
* @param sArg a string
* @return corresponding Level
*
*/
Convert the string passed as argument to a level. If the
conversion fails, then this method returns {@link #DEBUG}.
*/
public static Level toLevel(String sArg) {
return (Level) toLevel(sArg, Level.DEBUG);
}
/**
* Convert an integer passed as argument to a level. If the conversion fails,
* then this method returns {@link #DEBUG}.
*
* @param val an int
* @return a level
*/
Convert an integer passed as argument to a level. If the
conversion fails, then this method returns {@link #DEBUG}.
*/
public static Level toLevel(int val) {
return (Level) toLevel(val, Level.DEBUG);
}
/**
* Convert an integer passed as argument to a level. If the conversion fails,
* then this method returns the specified default.
*
* @param val a value
* @param defaultLevel a defaultLevel
* @return corresponding Level
*/
Convert an integer passed as argument to a level. If the
conversion fails, then this method returns the specified default.
*/
public static Level toLevel(int val, Level defaultLevel) {
switch (val) {
case ALL_INT:
@ -168,13 +150,10 @@ public class Level extends Priority implements Serializable {
}
/**
* Convert the string passed as argument to a level. If the conversion fails,
* then this method returns the value of <code>defaultLevel</code>.
*
* @param sArg a string
* @param defaultLevel a default level
* @return corresponding level
*/
Convert the string passed as argument to a level. If the
conversion fails, then this method returns the value of
<code>defaultLevel</code>.
*/
public static Level toLevel(String sArg, Level defaultLevel) {
if (sArg == null)
return defaultLevel;
@ -202,9 +181,8 @@ public class Level extends Priority implements Serializable {
/**
* Custom deserialization of Level.
*
* @param s serialization stream.
* @throws IOException if IO exception.
* @throws IOException if IO exception.
* @throws ClassNotFoundException if class not found.
*/
private void readObject(final ObjectInputStream s) throws IOException, ClassNotFoundException {
@ -219,7 +197,6 @@ public class Level extends Priority implements Serializable {
/**
* Serialize level.
*
* @param s serialization stream.
* @throws IOException if exception during serialization.
*/
@ -231,9 +208,8 @@ public class Level extends Priority implements Serializable {
}
/**
* Resolved deserialized level to one of the stock instances. May be overridden
* in classes derived from Level.
*
* Resolved deserialized level to one of the stock instances.
* May be overridden in classes derived from Level.
* @return resolved object.
* @throws ObjectStreamException if exception during resolution.
*/

View File

@ -33,7 +33,7 @@ import java.util.concurrent.ConcurrentMap;
class Log4jLoggerFactory {
// String, Logger
private static final ConcurrentMap<String, Logger> log4jLoggers = new ConcurrentHashMap<>();
private static ConcurrentMap<String, Logger> log4jLoggers = new ConcurrentHashMap<String, Logger>();
public static Logger getLogger(String name) {
org.apache.log4j.Logger instance = log4jLoggers.get(name);

View File

@ -22,11 +22,12 @@ import java.util.Enumeration;
import java.util.Vector;
/**
* <p>
* <p/>
* This class is a minimal implementation of the original
* <code>org.apache.log4j.LogManager</code> class (as found in log4j 1.2)
* delegating all calls to SLF4J.
* <p>
* <p/>
* <p/>
* This implementation does <b>NOT</b> implement the setRepositorySelector(),
* getLoggerRepository(), exists(), getCurrentLoggers(), shutdown() and
* resetConfiguration() methods which do not have SLF4J equivalents.
@ -66,7 +67,7 @@ public class LogManager {
/**
* This bogus implementation returns an empty enumeration.
*
* @return an Enumeration of current loggers
* @return
*/
public static Enumeration getCurrentLoggers() {
return new Vector().elements();

View File

@ -24,7 +24,7 @@ import org.slf4j.spi.LocationAwareLogger;
* This class is a minimal implementation of the original
* <code>org.apache.log4j.Logger</code> class (as found in log4j 1.2)
* delegating all calls to a {@link org.slf4j.Logger} instance.
*
* </p>
*
* @author Ceki G&uuml;lc&uuml;
* */
@ -52,7 +52,7 @@ public class Logger extends Category {
/**
* Does the obvious.
*
* @return the root logger
* @return
*/
public static Logger getRootLogger() {
return Log4jLoggerFactory.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME);
@ -61,8 +61,6 @@ public class Logger extends Category {
/**
* Delegates to {@link org.slf4j.Logger#isTraceEnabled}
* method of SLF4J.
*
* @return whether this logger is enabled for the level TRACE
*/
public boolean isTraceEnabled() {
return slf4jLogger.isTraceEnabled();
@ -70,9 +68,6 @@ public class Logger extends Category {
/**
* Delegates to {@link org.slf4j.Logger#trace(String)} method in SLF4J.
*
* @param message the message to log
*
*/
public void trace(Object message) {
differentiatedLog(null, LOGGER_FQCN, LocationAwareLogger.TRACE_INT, message, null);
@ -81,12 +76,9 @@ public class Logger extends Category {
/**
* Delegates to {@link org.slf4j.Logger#trace(String,Throwable)}
* method in SLF4J.
*
* @param message the message to log
* @param t a Throwable to log
*/
public void trace(Object message, Throwable t) {
differentiatedLog(null, LOGGER_FQCN, LocationAwareLogger.TRACE_INT, message, t);
differentiatedLog(null, LOGGER_FQCN, LocationAwareLogger.TRACE_INT, message, null);
}
}

View File

@ -49,8 +49,6 @@ public class MDC {
* This method is not part of the Log4J public API. However it
* has been called by other projects. This method is here temporarily
* until projects who are depending on this method release fixes.
*
* @return a copy of the underlying map returned as a Hashtable
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
@Deprecated

View File

@ -20,7 +20,7 @@ package org.apache.log4j;
/**
* This class is a minimal implementation of the original Log4J class.
*
* @author Christian Trutz
* @author Christian Trutz <christian.trutz@belaso.de>
* */
public class PatternLayout extends Layout {

View File

@ -21,8 +21,8 @@ package org.apache.log4j;
// Contributors: Kitching Simon <Simon.Kitching@OOOrange.ch>
/**
<b>Refrain from using this class directly, use
the {@link Level} class instead</b>.
<font color="#AA4444">Refrain from using this class directly, use
the {@link Level} class instead</font>.
@author Ceki G&uuml;lc&uuml; */
public class Priority {
@ -48,25 +48,21 @@ public class Priority {
/**
* @deprecated Use {@link Level#ERROR} instead.
*/
@Deprecated
final static public Priority ERROR = new Level(ERROR_INT, "ERROR", 3);
/**
* @deprecated Use {@link Level#WARN} instead.
*/
@Deprecated
final static public Priority WARN = new Level(WARN_INT, "WARN", 4);
/**
* @deprecated Use {@link Level#INFO} instead.
*/
@Deprecated
final static public Priority INFO = new Level(INFO_INT, "INFO", 6);
/**
* @deprecated Use {@link Level#DEBUG} instead.
*/
@Deprecated
final static public Priority DEBUG = new Level(DEBUG_INT, "DEBUG", 7);
/**
@ -80,15 +76,6 @@ public class Priority {
/**
Instantiate a level object.
@param
*/
/**
* Instantiate a level object.
*
* @param level a level as in int
* @param levelStr a levelStr
* @param syslogEquivalent the syslog equivalent level integer
*/
protected Priority(int level, String levelStr, int syslogEquivalent) {
this.level = level;
@ -111,23 +98,20 @@ public class Priority {
/**
Return the syslog equivalent of this priority as an integer.
@return the Syslog Equivalent of this Priority
*/
public final int getSyslogEquivalent() {
return syslogEquivalent;
}
/**
* Returns <code>true</code> if this level has a higher or equal
* level than the level passed as argument, <code>false</code>
* otherwise.
*
* <p>You should think twice before overriding the default
* implementation of <code>isGreaterOrEqual</code> method.
*
* @param r a priority
* @return a boolean
*/
Returns <code>true</code> if this level has a higher or equal
level than the level passed as argument, <code>false</code>
otherwise.
<p>You should think twice before overriding the default
implementation of <code>isGreaterOrEqual</code> method.
*/
public boolean isGreaterOrEqual(Priority r) {
return level >= r.level;
}
@ -135,11 +119,9 @@ public class Priority {
/**
Return all possible priorities as an array of Level objects in
descending order.
@deprecated This method will be removed with no replacement.
@return array of all possible priorities
*/
@Deprecated
public static Priority[] getAllPossiblePriorities() {
return new Priority[] { Priority.FATAL, Priority.ERROR, Level.WARN, Priority.INFO, Priority.DEBUG };
}
@ -152,9 +134,7 @@ public class Priority {
}
/**
* Returns the integer representation of this level.
*
* @return integer representation of this level
Returns the integer representation of this level.
*/
public final int toInt() {
return level;
@ -162,46 +142,29 @@ public class Priority {
/**
* @deprecated Please use the {@link Level#toLevel(String)} method instead.
*
* @param sArg a string to convert to a Priority
* @return the corresponding Priority
*/
@Deprecated
public static Priority toPriority(String sArg) {
return Level.toLevel(sArg);
}
/**
* @deprecated Please use the {@link Level#toLevel(int)} method instead.
*
* @param val an integer to convert to a Priority
* @return the corresponding Priority
*/
@Deprecated
public static Priority toPriority(int val) {
return toPriority(val, Priority.DEBUG);
}
/**
* @deprecated Please use the {@link Level#toLevel(int, Level)} method instead.
*
* @param val an integer value
* @param defaultPriority a default priority value
* @return corresponding Priority value
*/
@Deprecated
*/
public static Priority toPriority(int val, Priority defaultPriority) {
return Level.toLevel(val, (Level) defaultPriority);
}
/**
* @deprecated Please use the {@link Level#toLevel(String, Level)} method instead.
* @param sArg string value
* @param defaultPriority a default Priority
* @return a Priority
*/
@Deprecated
public static Priority toPriority(String sArg, Priority defaultPriority) {
return Level.toLevel(sArg, (Level) defaultPriority);
}
}
}

View File

@ -23,7 +23,7 @@ import org.apache.log4j.spi.Configurator;
import org.apache.log4j.spi.LoggerRepository;
/**
* A no-op implementation of PropertyConfigurator.
* An nop implementation of PropertyConfigurator.
*/
public class PropertyConfigurator implements Configurator {
public static void configure(Properties properties) {

View File

@ -22,7 +22,7 @@ import java.io.IOException;
/**
* This class is a minimal implementation of the original Log4J class.
*
* @author Christian Trutz
* @author Christian Trutz <christian.trutz@belaso.de>
* */
public class RollingFileAppender {

View File

@ -25,7 +25,7 @@ package org.apache.log4j.helpers;
<b>log4j.configDebug</b> variable.
<p>All log4j internal debug calls go to <code>System.out</code>
whereas internal error messages are sent to
where as internal error messages are sent to
<code>System.err</code>. All internal messages are prepended with
the string "log4j: ".
@ -37,20 +37,20 @@ public class LogLog {
/**
Defining this value makes log4j print log4j-internal debug
statements to <code>System.out</code>.
<p> The value of this string is <b>log4j.debug</b>.
<p>Note that the search for all option names is case-sensitive. */
<p>Note that the search for all option names is case sensitive. */
public static final String DEBUG_KEY = "log4j.debug";
/**
Defining this value makes log4j components print log4j-internal
debug statements to <code>System.out</code>.
<p> The value of this string is <b>log4j.configDebug</b>.
<p>Note that the search for all option names is case-sensitive.
<p>Note that the search for all option names is case sensitive.
@deprecated Use {@link #DEBUG_KEY} instead.
*/
public static final String CONFIG_DEBUG_KEY = "log4j.configDebug";
@ -127,7 +127,7 @@ public class LogLog {
/**
In quite mode no LogLog generates strictly no output, not even
for errors.
@param quietMode A true for not
*/
public static void setQuietMode(boolean quietMode) {

View File

@ -16,6 +16,7 @@
package org.apache.log4j.spi;
import org.apache.log4j.spi.LoggerRepository;
import java.net.URL;
/**
@ -40,10 +41,10 @@ public interface Configurator {
/**
Interpret a resource pointed by a URL and set up log4j accordingly.
The configuration is done relative to the <code>hierarchy</code>
parameter.
@param url The URL to parse
@param repository The hierarchy to operation upon.
*/

View File

@ -21,7 +21,7 @@ import org.apache.log4j.Logger;
/**
Implement this interface to create new instances of Logger or
a subclass of Logger.
a sub-class of Logger.
<p>See <code>examples/subclass/MyLogger.java</code> for an example.

View File

@ -25,7 +25,7 @@ import java.util.Enumeration;
* <code>Loggers</code>. The relation between loggers in a repository
* depends on the repository but typically loggers are arranged in a
* named hierarchy.
*
* <p/>
* <p>In addition to the creational methods, a
* <code>LoggerRepository</code> can be queried for existing loggers,
* can act as a point of registry for events related to loggers.
@ -37,8 +37,6 @@ public interface LoggerRepository {
/**
* Add a {@link HierarchyEventListener} event to the repository.
*
* @param listener a listener
*/
public void addHierarchyEventListener(HierarchyEventListener listener);

View File

@ -1,8 +0,0 @@
module log4j {
requires org.slf4j;
requires java.xml;
exports org.apache.log4j;
exports org.apache.log4j.helpers;
exports org.apache.log4j.spi;
exports org.apache.log4j.xml;
}

View File

@ -0,0 +1,14 @@
Implementation-Title: log4j-over-slf4j
Bundle-ManifestVersion: 2
Bundle-SymbolicName: log4j.over.slf4j
Bundle-Name: log4j-over-slf4j
Bundle-Vendor: SLF4J.ORG
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Automatic-Module-Name: org.apache.log4j
Export-Package: org.apache.log4j;version=${log4j.version},
org.apache.log4j.helpers;version=${log4j.version},
org.apache.log4j.spi;version=${log4j.version},
org.apache.log4j.xml;version=${log4j.version}
Import-Package: org.slf4j;version=${slf4j.api.minimum.compatible.version},
org.slf4j.helpers;version=${slf4j.api.minimum.compatible.version},
org.slf4j.spi;version=${slf4j.api.minimum.compatible.version}

View File

@ -22,7 +22,7 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
package org.apache.log4j.test;
package org.apache.log4j;
import static org.junit.Assert.assertEquals;
@ -30,8 +30,6 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.apache.log4j.NDC;
/**
* @author Ceki G&uuml;lc&uuml;
*/

View File

@ -22,7 +22,7 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
package org.apache.log4j.test;
package org.apache.log4j;
import org.apache.log4j.Logger;

View File

@ -31,7 +31,7 @@ import java.util.logging.LogRecord;
public class ListHandler extends Handler {
List<LogRecord> list = new ArrayList<>();
List<LogRecord> list = new ArrayList<LogRecord>();
public void close() throws SecurityException {

View File

@ -1,24 +0,0 @@
Copyright (c) 2004-2022 QOS.ch Sarl (Switzerland)
All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@ -7,8 +7,7 @@
<parent>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-parent</artifactId>
<version>2.0.19-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
<version>1.7.33</version>
</parent>
<artifactId>osgi-over-slf4j</artifactId>
@ -38,27 +37,10 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<configuration>
<instructions>
<Bundle-SymbolicName>org.slf4j.osgi-over-slf4j</Bundle-SymbolicName>
<Bundle-Activator>org.slf4j.osgi.logservice.impl.Activator</Bundle-Activator>
<Bundle-Category>osgi</Bundle-Category>
<_exportcontents combine.self="override" />
</instructions>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,8 @@
Implementation-Title: osgi-over-slf4j
Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.slf4j.osgi-over-slf4j
Bundle-Name: OSGi LogService implemented over SLF4J
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-Activator: org.slf4j.osgi.logservice.impl.Activator
Bundle-Category: osgi
Import-Package: org.osgi.framework;version="[1.5,2)",org.osgi.service.log;version="[1.3,2)",org.slf4j;version=${parsedVersion.osgiVersion}

View File

@ -1,397 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-bom</artifactId>
<version>2.0.19-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>slf4j-parent</artifactId>
<packaging>pom</packaging>
<name>SLF4J Parent POM</name>
<description>SLF4J project parent pom.xml file</description>
<organization>
<name>QOS.ch</name>
<url>http://www.qos.ch</url>
</organization>
<inceptionYear>2005</inceptionYear>
<properties>
<!-- yyyy-MM-dd'T'HH:mm:ss'Z' -->
<project.build.outputTimestamp>2026-05-12T18:37:04Z</project.build.outputTimestamp>
<latest.1.version>1.7.36</latest.1.version>
<!-- java.util.ServiceLoader requires Java 6 -->
<jdk.version>8</jdk.version>
<maven.compiler.source>${jdk.version}</maven.compiler.source>
<maven.compiler.target>${jdk.version}</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.build.resourceEncoding>UTF-8</project.build.resourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<!-- used in integration testing -->
<cal10n.version>0.8.1</cal10n.version>
<reload4j.version>1.2.22</reload4j.version>
<logback.version>1.2.10</logback.version>
<jcl.version>1.2</jcl.version>
<junit.version>4.13.1</junit.version>
<maven-site-plugin.version>3.7.1</maven-site-plugin.version>
<maven-compiler-plugin.version>3.10.1</maven-compiler-plugin.version>
<maven-surefire-plugin.version>3.0.0-M7</maven-surefire-plugin.version>
<maven-javadoc-plugin.version>3.6.3</maven-javadoc-plugin.version>
<maven-source-plugin.version>3.2.1</maven-source-plugin.version>
<maven-deploy-plugin.version>3.0.0-M1</maven-deploy-plugin.version>
<maven-jar-plugin.version>3.2.0</maven-jar-plugin.version>
<maven-jxr-plugin.version>3.1.1</maven-jxr-plugin.version>
<maven-bundle-plugin.version>5.1.9</maven-bundle-plugin.version>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>ch.qos.reload4j</groupId>
<artifactId>reload4j</artifactId>
<version>${reload4j.version}</version>
</dependency>
<dependency>
<groupId>ch.qos.cal10n</groupId>
<artifactId>cal10n-api</artifactId>
<version>${cal10n.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ssh</artifactId>
<version>2.10</version>
</extension>
</extensions>
<resources>
<resource>
<directory>${project.basedir}/src/main/resources</directory>
<filtering>true</filtering>
</resource>
<resource>
<directory>..</directory>
<targetPath>META-INF</targetPath>
<includes>
<include>LICENSE.txt</include>
</includes>
</resource>
</resources>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>animal-sniffer-maven-plugin</artifactId>
<version>1.14</version>
<configuration>
<signature>
<groupId>org.codehaus.mojo.signature</groupId>
<artifactId>java16</artifactId>
<version>1.0</version>
</signature>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>${maven-deploy-plugin.version}</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<executions>
<execution>
<id>default-compile</id>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
</configuration>
</execution>
<execution>
<id>module-compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<release>9</release>
<compileSourceRoots>
<compileSourceRoot>${project.basedir}/src/main/java9</compileSourceRoot>
</compileSourceRoots>
<multiReleaseOutput>true</multiReleaseOutput>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>${maven-jar-plugin.version}</version>
<executions>
<!-- Repeated in slf4j-api/pom.xml -->
<execution>
<id>default-jar</id>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<archive>
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
</archive>
<skipIfEmpty>true</skipIfEmpty>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>${maven-bundle-plugin.version}</version>
<configuration>
<supportIncrementalBuild>true</supportIncrementalBuild>
<!-- populated by the plugin itself -->
<instructions>
<Bundle-SymbolicName>${replacestring;${project.artifactId};-;.}</Bundle-SymbolicName>
<Bundle-Vendor>SLF4J.ORG</Bundle-Vendor>
<_snapshot/>
<_exportcontents>!META-INF.versions.9,*;-noimport:=true</_exportcontents>
<Bundle-Description>${project.description}</Bundle-Description>
<Bundle-DocURL>${project.url}</Bundle-DocURL>
<X-Compile-Source-JDK>${maven.compiler.source}</X-Compile-Source-JDK>
<X-Compile-Target-JDK>${maven.compiler.target}</X-Compile-Target-JDK>
<Implementation-Version>${project.version}</Implementation-Version>
<Implementation-Title>${project.artifactId}</Implementation-Title>
<Multi-Release>true</Multi-Release>
<_removeheaders>Private-Package,Bundle-SCM, Bundle-Developers, Include-Resource</_removeheaders>
</instructions>
</configuration>
<executions>
<execution>
<id>bundle-manifest</id>
<phase>process-classes</phase>
<goals>
<goal>manifest</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<configuration>
<forkCount>1</forkCount>
<reuseForks>false</reuseForks>
<reportFormat>plain</reportFormat>
<trimStackTrace>false</trimStackTrace>
<excludes>
<exclude>**/AllTest.java</exclude>
<exclude>**/PackageTest.java</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>${maven-source-plugin.version}</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>${maven-site-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>skipTests</id>
<properties>
<maven.test.skip>true</maven.test.skip>
</properties>
</profile>
<profile>
<id>javadocjar</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>${maven-javadoc-plugin.version}</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
<configuration>
<additionalparam>-Xdoclint:none</additionalparam>
<failOnError>false</failOnError>
<sourceFileExcludes>
<sourceFileExclude>**/module-info.java</sourceFileExclude>
</sourceFileExcludes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>license</id>
<build>
<plugins>
<plugin>
<groupId>com.google.code.maven-license-plugin</groupId>
<artifactId>maven-license-plugin</artifactId>
<configuration>
<header>src/main/licenseHeader.txt</header>
<quiet>false</quiet>
<failIfMissing>true</failIfMissing>
<aggregate>true</aggregate>
<includes>
<include>src/**/*.java</include>
</includes>
<useDefaultExcludes>true</useDefaultExcludes>
<useDefaultMapping>true</useDefaultMapping>
<properties>
<year>1999</year>
</properties>
<headerDefinitions>
<headerDefinition>src/main/javadocHeaders.xml</headerDefinition>
</headerDefinitions>
</configuration>
</plugin>
</plugins>
</build>
<pluginRepositories>
</pluginRepositories>
</profile>
<profile>
<id>generate-osgi-service-loader-mediator-entries</id>
<activation>
<file>
<exists>src/main/resources/META-INF/services/org.slf4j.spi.SLF4JServiceProvider</exists>
</file>
</activation>
<build>
<!-- Add the OSGi Service Loader Mediator Specification Manifest entries for each module that has a SLF4JServiceProvider Service-Loader file.-->
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<configuration>
<instructions>
<Provide-Capability><![CDATA[
osgi.service;objectClass:List<String>="org.slf4j.spi.SLF4JServiceProvider";type=${slf4j.provider.type};effective:=active,
osgi.serviceloader;osgi.serviceloader="org.slf4j.spi.SLF4JServiceProvider";register:="${slf4j.provider.implementation}";type=${slf4j.provider.type}
]]></Provide-Capability>
<Require-Capability><![CDATA[
osgi.extender;filter:="(&(osgi.extender=osgi.serviceloader.registrar)(version>=1.0.0)(!(version>=2.0.0)))"
]]></Require-Capability>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<!--
<profile>
<id>travis</id>
<activation>
<property>
<name>env.TRAVIS</name>
<value>true</value>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-toolchains-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<id>toolchain</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
-->
</profiles>
</project>

493
pom.xml
View File

@ -5,53 +5,88 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-bom</artifactId>
<version>2.0.19-SNAPSHOT</version>
<packaging>pom</packaging>
<artifactId>slf4j-parent</artifactId>
<version>1.7.33</version>
<packaging>pom</packaging>
<name>SLF4J</name>
<description>Top SLF4J project pom.xml file</description>
<url>http://www.slf4j.org</url>
<name>SLF4J BOM</name>
<description>SLF4J project BOM</description>
<organization>
<name>QOS.ch</name>
<url>http://www.qos.ch</url>
</organization>
<inceptionYear>2005</inceptionYear>
<licenses>
<license>
<name>MIT</name>
<url>https://opensource.org/license/mit</url>
<name>MIT License</name>
<url>http://www.opensource.org/licenses/mit-license.php</url>
<distribution>repo</distribution>
</license>
</licenses>
<scm>
<url>https://github.com/qos-ch/slf4j</url>
<connection>scm:git:https://github.com/qos-ch/slf4j.git</connection>
</scm>
<connection>git@github.com:qos-ch/slf4j.git</connection>
</scm>
<properties>
<required.jdk.version>1.5</required.jdk.version>
<maven.compiler.source>${required.jdk.version}</maven.compiler.source>
<maven.compiler.target>${required.jdk.version}</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.build.resourceEncoding>UTF-8</project.build.resourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<!-- used in integration testing -->
<slf4j.api.minimum.compatible.version>1.6.0</slf4j.api.minimum.compatible.version>
<cal10n.version>0.8.1</cal10n.version>
<log4j.version>1.2.17</log4j.version>
<reload4j.version>1.2.18.0</reload4j.version>
<logback.version>1.0.13</logback.version>
<junit.version>4.12</junit.version>
<maven-site-plugin.version>3.3</maven-site-plugin.version>
<maven-source-plugin.version>3.0.1</maven-source-plugin.version>
<javadoc.plugin.version>3.1.0</javadoc.plugin.version>
<doclint>none</doclint>
</properties>
<developers>
<developer>
<id>ceki</id>
<name>Ceki Gulcu</name>
<email>ceki@qos.ch</email>
</developer>
</developers>
<!-- Inspired by Improving the Maven Bill of Materials (BOM) Pattern -->
<!-- https://www.garretwilson.com/blog/2023/06/14/improve-maven-bom-pattern -->
<modules>
<module>parent</module>
<module>slf4j-api</module>
<module>slf4j-simple</module>
<module>slf4j-nop</module>
<module>slf4j-jdk14</module>
<module>slf4j-jdk-platform-logging</module>
<module>slf4j-log4j12</module>
<module>slf4j-reload4j</module>
<module>slf4j-reload4j</module>
<module>slf4j-jcl</module>
<module>slf4j-android</module>
<module>slf4j-ext</module>
<module>jcl-over-slf4j</module>
<module>log4j-over-slf4j</module>
<module>jul-to-slf4j</module>
<module>osgi-over-slf4j</module>
<module>integration</module>
<module>slf4j-site</module>
<module>slf4j-migrator</module>
</modules>
<properties>
<central-publishing-maven-plugin.version>0.9.0</central-publishing-maven-plugin.version>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
@ -62,183 +97,302 @@
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-nop</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk-platform-logging</artifactId>
<version>${project.version}</version>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${project.version}</version>
<groupId>ch.qos.reload4j</groupId>
<artifactId>reload4j</artifactId>
<version>${reload4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-reload4j</artifactId>
<version>${project.version}</version>
<groupId>ch.qos.cal10n</groupId>
<artifactId>cal10n-api</artifactId>
<version>${cal10n.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-ext</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>log4j-over-slf4j</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jul-to-slf4j</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>osgi-over-slf4j</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
<distributionManagement>
<repository>
<id>sonatype-nexus-staging</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>
<developers>
<developer>
<id>ceki</id>
<name>Ceki Gulcu</name>
<email>ceki@qos.ch</email>
</developer>
</developers>
<build>
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ssh</artifactId>
<version>2.0</version>
</extension>
</extensions>
<resources>
<resource>
<directory>${project.basedir}/src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>animal-sniffer-maven-plugin</artifactId>
<version>1.14</version>
<configuration>
<signature>
<groupId>org.codehaus.mojo.signature</groupId>
<artifactId>java15</artifactId>
<version>1.0</version>
</signature>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.6.3</version>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<verbose>true</verbose>
<skippedModules>
slf4j-jdk-platform-logging,slf4j-migrator,osgi-over-slf4j
</skippedModules>
<detectLinks>true</detectLinks>
<doctitle>SLF4J project modules ${project.version}</doctitle>
<windowtitle>SLF4J javadoc</windowtitle>
<bottom><![CDATA[Copyright &copy; 2005-{currentYear} QOS.CH Sarl. All rights reserved]]></bottom>
<linksource>true</linksource>
<additionalOptions>
<additionalOption>-Xdoclint:none</additionalOption>
</additionalOptions>
<groups>
<group>
<title>SLF4J API packages</title>
<packages>org.slf4j:org.slf4j.spi:org.slf4j.event:org.slf4j.helpers</packages>
</group>
<group>
<title>slf4j-simple package</title>
<packages>org.slf4j.simple</packages>
</group>
<group>
<title>slf4j-nop package</title>
<packages>org.slf4j.nop</packages>
</group>
<group>
<title>slf4j-jdk14 package</title>
<packages>org.slf4j.jul</packages>
</group>
<group>
<title>slf4j-reload4j package</title>
<packages>org.slf4j.reload4j</packages>
</group>
<group>
<title>SLF4J extensions</title>
<packages>
org.slf4j.cal10n:org.slf4j.profiler:org.slf4j.ext:org.slf4j.instrumentation:org.slf4j.agent
</packages>
</group>
<group>
<title>Jakarta Commons Logging packages</title>
<packages>org.apache.commons.*</packages>
</group>
<group>
<title>java.util.logging (JUL) to SLF4J bridge</title>
<packages>org.slf4j.bridge</packages>
</group>
<group>
<title>log4j-over-slf4j redirection</title>
<packages>org.apache.log4j:org.apache.log4j.*</packages>
</group>
</groups>
<source>${required.jdk.version}</source>
<target>${required.jdk.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.sonatype.central</groupId>
<artifactId>central-publishing-maven-plugin</artifactId>
<version>${central-publishing-maven-plugin.version}</version>
<extensions>true</extensions>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<publishingServerId>central</publishingServerId>
<excludeArtifacts>integration</excludeArtifacts>
<archive>
<manifestEntries>
<Bundle-Version>${parsedVersion.osgiVersion}</Bundle-Version>
<Bundle-Description>${project.description}</Bundle-Description>
<X-Compile-Source-JDK>${maven.compiler.source}</X-Compile-Source-JDK>
<X-Compile-Target-JDK>${maven.compiler.target}</X-Compile-Target-JDK>
<Implementation-Version>${project.version}</Implementation-Version>
</manifestEntries>
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
</archive>
<skipIfEmpty>true</skipIfEmpty>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>${maven-source-plugin.version}</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<forkCount>2C</forkCount>
<reuseForks>true</reuseForks>
<reportFormat>plain</reportFormat>
<trimStackTrace>false</trimStackTrace>
<excludes>
<exclude>**/AllTest.java</exclude>
<exclude>**/PackageTest.java</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2</version>
<configuration>
<descriptors>
<descriptor>src/main/assembly/source.xml</descriptor>
</descriptors>
<finalName>slf4j-${project.version}</finalName>
<appendAssemblyId>false</appendAssemblyId>
<outputDirectory>target/site/dist/</outputDirectory>
</configuration>
</plugin>
<!-- as suggested in http://jira.qos.ch/browse/SLF4J-143 -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>parse-version</id>
<goals>
<goal>parse-version</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- ====== site plugin ===== -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>${maven-site-plugin.version}</version>
<configuration>
<reportPlugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
<version>2.3</version>
<configuration>
<aggregate>true</aggregate>
<javadocDir>target/site/apidocs/</javadocDir>
<linkJavadoc>true</linkJavadoc>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>${javadoc.plugin.version}</version>
<configuration>
<linksource>true</linksource>
<doclint>none</doclint>
<!--<aggregate>true</aggregate>-->
<excludePackageNames>org.slf4j.migrator:org.slf4j.migrator.*</excludePackageNames>
<links>
<link>
http://java.sun.com/j2se/1.5.0/docs/api
</link>
</links>
<groups>
<group>
<title>SLF4J packages</title>
<packages>org.slf4j:org.slf4j.*</packages>
</group>
<group>
<title>SLF4J extensions</title>
<packages>
org.slf4j.cal10n:org.slf4j.profiler:org.slf4j.ext:org.slf4j.instrumentation:org.slf4j.agent
</packages>
</group>
<group>
<title>Jakarta Commons Logging packages</title>
<packages>org.apache.commons.*</packages>
</group>
<group>
<title>java.util.logging (JUL) to SLF4J bridge</title>
<packages>org.slf4j.bridge</packages>
</group>
<group>
<title>Apache log4j</title>
<packages>org.apache.log4j:org.apache.log4j.*</packages>
</group>
</groups>
</configuration>
</plugin>
</reportPlugins>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>skipTests</id>
<properties>
<maven.test.skip>true</maven.test.skip>
</properties>
</profile>
<profile>
<id>javadocjar</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>${javadoc.plugin.version}</version>
<configuration>
<doclint>none</doclint>
</configuration>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>license</id>
<build>
<plugins>
<plugin>
<groupId>com.google.code.maven-license-plugin</groupId>
<artifactId>maven-license-plugin</artifactId>
<configuration>
<header>src/main/licenseHeader.txt</header>
<quiet>false</quiet>
<failIfMissing>true</failIfMissing>
<aggregate>true</aggregate>
<includes>
<include>src/**/*.java</include>
</includes>
<useDefaultExcludes>true</useDefaultExcludes>
<useDefaultMapping>true</useDefaultMapping>
<properties>
<year>1999</year>
</properties>
<headerDefinitions>
<headerDefinition>src/main/javadocHeaders.xml</headerDefinition>
</headerDefinitions>
</configuration>
</plugin>
</plugins>
</build>
<pluginRepositories>
<pluginRepository>
<id>mc-release</id>
<name>Local Maven repository of releases</name>
<url>http://mc-repo.googlecode.com/svn/maven2/releases</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</pluginRepository>
</pluginRepositories>
</profile>
<profile>
<id>sign-artifacts</id>
@ -261,6 +415,25 @@
</plugins>
</build>
</profile>
</profiles>
<pluginRepositories>
</pluginRepositories>
<distributionManagement>
<site>
<id>qos_ch</id>
<url>scp://te.qos.ch/var/www/www.slf4j.org/htdocs/</url>
</site>
<repository>
<!--<id>pixie</id>-->
<!--<url>scp://pixie.qos.ch/var/mvnrepo/</url>-->
<id>sonatype-nexus-staging</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>
</project>

View File

@ -1,18 +1,10 @@
# Javadoc
#JDK8 - mvn site:site
#rscpSLF4J apidocs/
# JDK 11+
# adding the following
#mvn -Ddoclint=none -Dadditionalparam=-Xdoclint:none javadoc:aggregate
#mvn versions:set -DgenerateBackupPoms=false -DnewVersion=${VERSION_NUMBER}
MVN='/java/maven-3.5.2//bin/mvn'
PASS=$1
echo $PASS
function checkExit(){
if test "$?" != "0"; then
echo Command $1 exited with abnormal status
@ -21,42 +13,37 @@ function checkExit(){
fi
}
function echoRunAndCheck () { # echo and then run the command
function echoThenRun () { # echo and then run the command
echo $1
$1
ret=$?
if test "$ret" != "0";
then
echo Failed command: $1
exit 1;
else echo Successful run: $1
fi
echo $ret
return $ret
}
echoRunAndCheck "$MVN clean"
echoRunAndCheck "$MVN install"
#echoRunAndCheck "$MVN site:site"
#echoRunAndCheck "$MVN javadoc:aggregate"
#echoRunAndCheck "$MVN jxr:aggregate"
$MVN clean
checkExit "mvn clean"
if [ ! -z "$PASS" ]
then
# WARNING deploying without cleaning may leave stale MANIFEST files
export GPG_TTY=$(tty)
echoRunAndCheck "$MVN deploy -P javadocjar,sign-artifacts"
fi
$MVN install
checkExit "mvn install"
git tag -m "tagging" -a v_${VERSION_NUMBER}
git push --tags
#Update release version and add next version on jira
$MVN site:site
checkExit "mvn site:ste"
$MVN assembly:single
checkExit "mvn assembly:single"
echo Full Success
$MVN deploy -P javadocjar,sign-artifacts -Dgpg.passphrase=$PASS
checkExit "mvn deploy -P javadocjar,sign-artifacts -Dgpg.passphrase=xxx"
#$MVN site:deploy -N # with Java 8!!!
#checkExit "mvn site:deploy -N"
#git tag -m "tagging" -a v_${VERSION_NUMBER}
#git push --tags
#release version and add next version on jira

2
slf4j-android/.gitignore vendored Executable file
View File

@ -0,0 +1,2 @@
bin/
gen/

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.slf4j"
android:versionCode="176"
android:versionName="1.7.6">
<uses-sdk android:minSdkVersion="3" />
</manifest>

View File

@ -1,4 +1,4 @@
Copyright (c) 2004-2022 QOS.ch Sarl (Switzerland)
Copyright (c) 2004-2013 QOS.ch
All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining

34
slf4j-android/pom.xml Normal file
View File

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-parent</artifactId>
<version>1.7.33</version>
</parent>
<artifactId>slf4j-android</artifactId>
<packaging>jar</packaging>
<name>SLF4J Android Binding</name>
<description>SLF4J Android Binding</description>
<url>http://www.slf4j.org</url>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>1.5_r4</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,14 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system use,
# "ant.properties", and override values to adapt the script to your
# project structure.
android.library=true
# Indicates whether an apk should be generated for each density.
split.density=false
# Project target.
target=android-3

View File

@ -0,0 +1,552 @@
/*
* Copyright (c) 2004-2013 QOS.ch
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
package org.slf4j.impl;
import android.util.Log;
import org.slf4j.helpers.FormattingTuple;
import org.slf4j.helpers.MarkerIgnoringBase;
import org.slf4j.helpers.MessageFormatter;
/**
* <p>A simple implementation that delegates all log requests to the Google Android
* logging facilities. Note that this logger does not support {@link org.slf4j.Marker}.
* Methods taking marker data as parameter simply invoke the eponymous method
* without the Marker argument, discarding any marker data in the process.</p>
*
* <p>The logging levels specified for SLF4J can be almost directly mapped to
* the levels that exist in the Google Android platform. The following table
* shows the mapping implemented by this logger.</p>
*
* <table border="1">
* <tr><th><b>SLF4J<b></th><th><b>Android</b></th></tr>
* <tr><td>TRACE</td><td>{@link android.util.Log#VERBOSE}</td></tr>
* <tr><td>DEBUG</td><td>{@link android.util.Log#DEBUG}</td></tr>
* <tr><td>INFO</td><td>{@link android.util.Log#INFO}</td></tr>
* <tr><td>WARN</td><td>{@link android.util.Log#WARN}</td></tr>
* <tr><td>ERROR</td><td>{@link android.util.Log#ERROR}</td></tr>
* </table>
*
* <p>Use loggers as usual:
* <ul>
* <li>
* Declare a logger<br/>
* <code>private static final Logger logger = LoggerFactory.getLogger(MyClass.class);</code>
* </li>
* <li>
* Invoke logging methods, e.g.,<br/>
* <code>logger.debug("Some log message. Details: {}", someObject);</code><br/>
* <code>logger.debug("Some log message with varargs. Details: {}, {}, {}", someObject1, someObject2, someObject3);</code>
* </li>
* </ul>
* </p>
*
* <p>Logger instances created using the LoggerFactory are named either according to the name
* or the fully qualified class name of the class given as a parameter.
* Each logger name will be used as the log message tag on the Android platform.
* However, tag names cannot be longer than 23 characters so if logger name exceeds this limit then
* it will be truncated by the LoggerFactory. The following examples illustrate this.
* <table border="1">
* <tr><th><b>Original Name<b></th><th><b>Truncated Name</b></th></tr>
* <tr><td>org.example.myproject.mypackage.MyClass</td><td>o*.e*.m*.m*.MyClass</td></tr>
* <tr><td>o.e.myproject.mypackage.MyClass</td><td>o.e.m*.m*.MyClass</td></tr>
* <tr><td>org.example.ThisNameIsWayTooLongAndWillBeTruncated</td><td>*LongAndWillBeTruncated</td></tr>
* <tr><td>ThisNameIsWayTooLongAndWillBeTruncated</td><td>*LongAndWillBeTruncated</td></tr>
* </table>
* </p>
*
* @author Andrey Korzhevskiy <a.korzhevskiy@gmail.com>
*/
class AndroidLoggerAdapter extends MarkerIgnoringBase {
private static final long serialVersionUID = -1227274521521287937L;
/**
* Package access allows only {@link AndroidLoggerFactory} to instantiate
* SimpleLogger instances.
*/
AndroidLoggerAdapter(String tag) {
this.name = tag;
}
/**
* Is this logger instance enabled for the VERBOSE level?
*
* @return True if this Logger is enabled for level VERBOSE, false otherwise.
*/
public boolean isTraceEnabled() {
return isLoggable(Log.VERBOSE);
}
/**
* Log a message object at level VERBOSE.
*
* @param msg
* - the message object to be logged
*/
public void trace(String msg) {
log(Log.VERBOSE, msg, null);
}
/**
* Log a message at level VERBOSE according to the specified format and
* argument.
*
* <p>
* This form avoids superfluous object creation when the logger is disabled
* for level VERBOSE.
* </p>
*
* @param format
* the format string
* @param arg
* the argument
*/
public void trace(String format, Object arg) {
formatAndLog(Log.VERBOSE, format, arg);
}
/**
* Log a message at level VERBOSE according to the specified format and
* arguments.
*
* <p>
* This form avoids superfluous object creation when the logger is disabled
* for the VERBOSE level.
* </p>
*
* @param format
* the format string
* @param arg1
* the first argument
* @param arg2
* the second argument
*/
public void trace(String format, Object arg1, Object arg2) {
formatAndLog(Log.VERBOSE, format, arg1, arg2);
}
/**
* Log a message at level VERBOSE according to the specified format and
* arguments.
*
* <p>
* This form avoids superfluous object creation when the logger is disabled
* for the VERBOSE level.
* </p>
*
* @param format
* the format string
* @param argArray
* an array of arguments
*/
public void trace(String format, Object... argArray) {
formatAndLog(Log.VERBOSE, format, argArray);
}
/**
* Log an exception (throwable) at level VERBOSE with an accompanying message.
*
* @param msg
* the message accompanying the exception
* @param t
* the exception (throwable) to log
*/
public void trace(String msg, Throwable t) {
log(Log.VERBOSE, msg, t);
}
/**
* Is this logger instance enabled for the DEBUG level?
*
* @return True if this Logger is enabled for level DEBUG, false otherwise.
*/
public boolean isDebugEnabled() {
return isLoggable(Log.DEBUG);
}
/**
* Log a message object at level DEBUG.
*
* @param msg
* - the message object to be logged
*/
public void debug(String msg) {
log(Log.DEBUG, msg, null);
}
/**
* Log a message at level DEBUG according to the specified format and argument.
*
* <p>
* This form avoids superfluous object creation when the logger is disabled
* for level DEBUG.
* </p>
*
* @param format
* the format string
* @param arg
* the argument
*/
public void debug(String format, Object arg) {
formatAndLog(Log.DEBUG, format, arg);
}
/**
* Log a message at level DEBUG according to the specified format and
* arguments.
*
* <p>
* This form avoids superfluous object creation when the logger is disabled
* for the DEBUG level.
* </p>
*
* @param format
* the format string
* @param arg1
* the first argument
* @param arg2
* the second argument
*/
public void debug(String format, Object arg1, Object arg2) {
formatAndLog(Log.DEBUG, format, arg1, arg2);
}
/**
* Log a message at level DEBUG according to the specified format and
* arguments.
*
* <p>
* This form avoids superfluous object creation when the logger is disabled
* for the DEBUG level.
* </p>
*
* @param format
* the format string
* @param argArray
* an array of arguments
*/
public void debug(String format, Object... argArray) {
formatAndLog(Log.DEBUG, format, argArray);
}
/**
* Log an exception (throwable) at level DEBUG with an accompanying message.
*
* @param msg
* the message accompanying the exception
* @param t
* the exception (throwable) to log
*/
public void debug(String msg, Throwable t) {
log(Log.VERBOSE, msg, t);
}
/**
* Is this logger instance enabled for the INFO level?
*
* @return True if this Logger is enabled for the INFO level, false otherwise.
*/
public boolean isInfoEnabled() {
return isLoggable(Log.INFO);
}
/**
* Log a message object at the INFO level.
*
* @param msg
* - the message object to be logged
*/
public void info(String msg) {
log(Log.INFO, msg, null);
}
/**
* Log a message at level INFO according to the specified format and argument.
*
* <p>
* This form avoids superfluous object creation when the logger is disabled
* for the INFO level.
* </p>
*
* @param format
* the format string
* @param arg
* the argument
*/
public void info(String format, Object arg) {
formatAndLog(Log.INFO, format, arg);
}
/**
* Log a message at the INFO level according to the specified format and
* arguments.
*
* <p>
* This form avoids superfluous object creation when the logger is disabled
* for the INFO level.
* </p>
*
* @param format
* the format string
* @param arg1
* the first argument
* @param arg2
* the second argument
*/
public void info(String format, Object arg1, Object arg2) {
formatAndLog(Log.INFO, format, arg1, arg2);
}
/**
* Log a message at level INFO according to the specified format and
* arguments.
*
* <p>
* This form avoids superfluous object creation when the logger is disabled
* for the INFO level.
* </p>
*
* @param format
* the format string
* @param argArray
* an array of arguments
*/
public void info(String format, Object... argArray) {
formatAndLog(Log.INFO, format, argArray);
}
/**
* Log an exception (throwable) at the INFO level with an accompanying
* message.
*
* @param msg
* the message accompanying the exception
* @param t
* the exception (throwable) to log
*/
public void info(String msg, Throwable t) {
log(Log.INFO, msg, t);
}
/**
* Is this logger instance enabled for the WARN level?
*
* @return True if this Logger is enabled for the WARN level, false
* otherwise.
*/
public boolean isWarnEnabled() {
return isLoggable(Log.WARN);
}
/**
* Log a message object at the WARN level.
*
* @param msg
* - the message object to be logged
*/
public void warn(String msg) {
log(Log.WARN, msg, null);
}
/**
* Log a message at the WARN level according to the specified format and
* argument.
*
* <p>
* This form avoids superfluous object creation when the logger is disabled
* for the WARN level.
* </p>
*
* @param format
* the format string
* @param arg
* the argument
*/
public void warn(String format, Object arg) {
formatAndLog(Log.WARN, format, arg);
}
/**
* Log a message at the WARN level according to the specified format and
* arguments.
*
* <p>
* This form avoids superfluous object creation when the logger is disabled
* for the WARN level.
* </p>
*
* @param format
* the format string
* @param arg1
* the first argument
* @param arg2
* the second argument
*/
public void warn(String format, Object arg1, Object arg2) {
formatAndLog(Log.WARN, format, arg1, arg2);
}
/**
* Log a message at level WARN according to the specified format and
* arguments.
*
* <p>
* This form avoids superfluous object creation when the logger is disabled
* for the WARN level.
* </p>
*
* @param format
* the format string
* @param argArray
* an array of arguments
*/
public void warn(String format, Object... argArray) {
formatAndLog(Log.WARN, format, argArray);
}
/**
* Log an exception (throwable) at the WARN level with an accompanying
* message.
*
* @param msg
* the message accompanying the exception
* @param t
* the exception (throwable) to log
*/
public void warn(String msg, Throwable t) {
log(Log.WARN, msg, t);
}
/**
* Is this logger instance enabled for level ERROR?
*
* @return True if this Logger is enabled for level ERROR, false otherwise.
*/
public boolean isErrorEnabled() {
return isLoggable(Log.ERROR);
}
/**
* Log a message object at the ERROR level.
*
* @param msg
* - the message object to be logged
*/
public void error(String msg) {
log(Log.ERROR, msg, null);
}
/**
* Log a message at the ERROR level according to the specified format and
* argument.
*
* <p>
* This form avoids superfluous object creation when the logger is disabled
* for the ERROR level.
* </p>
*
* @param format
* the format string
* @param arg
* the argument
*/
public void error(String format, Object arg) {
formatAndLog(Log.ERROR, format, arg);
}
/**
* Log a message at the ERROR level according to the specified format and
* arguments.
*
* <p>
* This form avoids superfluous object creation when the logger is disabled
* for the ERROR level.
* </p>
*
* @param format
* the format string
* @param arg1
* the first argument
* @param arg2
* the second argument
*/
public void error(String format, Object arg1, Object arg2) {
formatAndLog(Log.ERROR, format, arg1, arg2);
}
/**
* Log a message at level ERROR according to the specified format and
* arguments.
*
* <p>
* This form avoids superfluous object creation when the logger is disabled
* for the ERROR level.
* </p>
*
* @param format
* the format string
* @param argArray
* an array of arguments
*/
public void error(String format, Object... argArray) {
formatAndLog(Log.ERROR, format, argArray);
}
/**
* Log an exception (throwable) at the ERROR level with an accompanying
* message.
*
* @param msg
* the message accompanying the exception
* @param t
* the exception (throwable) to log
*/
public void error(String msg, Throwable t) {
log(Log.ERROR, msg, t);
}
private void formatAndLog(int priority, String format, Object... argArray) {
if (isLoggable(priority)) {
FormattingTuple ft = MessageFormatter.arrayFormat(format, argArray);
logInternal(priority, ft.getMessage(), ft.getThrowable());
}
}
private void log(int priority, String message, Throwable throwable) {
if (isLoggable(priority)) {
logInternal(priority, message, throwable);
}
}
private boolean isLoggable(int priority) {
return Log.isLoggable(name, priority);
}
private void logInternal(int priority, String message, Throwable throwable) {
if (throwable != null) {
message += '\n' + Log.getStackTraceString(throwable);
}
Log.println(priority, name, message);
}
}

View File

@ -0,0 +1,123 @@
/*
* Copyright (c) 2004-2013 QOS.ch
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
package org.slf4j.impl;
import org.slf4j.ILoggerFactory;
import org.slf4j.Logger;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
/**
* AndroidLoggerFactory is an implementation of {@link ILoggerFactory} returning
* the appropriately named {@link AndroidLoggerFactory} instance.
*
* @author Andrey Korzhevskiy <a.korzhevskiy@gmail.com>
*/
class AndroidLoggerFactory implements ILoggerFactory {
static final String ANONYMOUS_TAG = "null";
static final int TAG_MAX_LENGTH = 23;
private final ConcurrentMap<String, Logger> loggerMap = new ConcurrentHashMap<String, Logger>();
/**
* Return an appropriate {@link AndroidLoggerAdapter} instance by name.
*/
public Logger getLogger(String name) {
String tag = loggerNameToTag(name);
Logger logger = loggerMap.get(tag);
if (logger == null) {
Logger newInstance = new AndroidLoggerAdapter(tag);
Logger oldInstance = loggerMap.putIfAbsent(tag, newInstance);
logger = oldInstance == null ? newInstance : oldInstance;
}
return logger;
}
/**
* Tag names cannot be longer than {@value #TAG_MAX_LENGTH} characters on Android platform.
*
* Returns the short logger tag (up to {@value #TAG_MAX_LENGTH} characters) for the given logger name.
* Traditionally loggers are named by fully-qualified Java classes; this
* method attempts to return a concise identifying part of such names.
*
* See also:
* android/system/core/include/cutils/property.h
* android/frameworks/base/core/jni/android_util_Log.cpp
* dalvik.system.DalvikLogging
*
*/
static String loggerNameToTag(String loggerName) {
// Anonymous logger
if (loggerName == null) {
return ANONYMOUS_TAG;
}
int length = loggerName.length();
if (length <= TAG_MAX_LENGTH) {
return loggerName;
}
int tagLength = 0;
int lastTokenIndex = 0;
int lastPeriodIndex;
StringBuilder tagName = new StringBuilder(TAG_MAX_LENGTH + 3);
while ((lastPeriodIndex = loggerName.indexOf('.', lastTokenIndex)) != -1) {
tagName.append(loggerName.charAt(lastTokenIndex));
// token of one character appended as is otherwise truncate it to one character
int tokenLength = lastPeriodIndex - lastTokenIndex;
if (tokenLength > 1) {
tagName.append('*');
}
tagName.append('.');
lastTokenIndex = lastPeriodIndex + 1;
// check if name is already too long
tagLength = tagName.length();
if (tagLength > TAG_MAX_LENGTH) {
return getSimpleName(loggerName);
}
}
// Either we had no useful dot location at all
// or last token would exceed TAG_MAX_LENGTH
int tokenLength = length - lastTokenIndex;
if (tagLength == 0 || (tagLength + tokenLength) > TAG_MAX_LENGTH) {
return getSimpleName(loggerName);
}
// last token (usually class name) appended as is
tagName.append(loggerName, lastTokenIndex, length);
return tagName.toString();
}
private static String getSimpleName(String loggerName) {
// Take leading part and append '*' to indicate that it was truncated
int length = loggerName.length();
int lastPeriodIndex = loggerName.lastIndexOf('.');
return lastPeriodIndex != -1 && length - (lastPeriodIndex + 1) <= TAG_MAX_LENGTH ? loggerName.substring(lastPeriodIndex + 1) : '*' + loggerName
.substring(length - TAG_MAX_LENGTH + 1);
}
}

View File

@ -0,0 +1,80 @@
/**
* Copyright (c) 2004-2013 QOS.ch
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
package org.slf4j.impl;
import org.slf4j.ILoggerFactory;
import org.slf4j.LoggerFactory;
import org.slf4j.spi.LoggerFactoryBinder;
/**
* The binding of {@link LoggerFactory} class with an actual instance of
* {@link ILoggerFactory} is performed using information returned by this class.
*
* @author Ceki G&uuml;lc&uuml;
* @author Andrey Korzhevskiy <a.korzhevskiy@gmail.com>
*/
public class StaticLoggerBinder implements LoggerFactoryBinder {
/**
* The unique instance of this class.
*/
private static final StaticLoggerBinder SINGLETON = new StaticLoggerBinder();
/**
* Return the singleton of this class.
*
* @return the StaticLoggerBinder singleton
*/
public static StaticLoggerBinder getSingleton() {
return SINGLETON;
}
/**
* Declare the version of the SLF4J API this implementation is compiled against.
* The value of this field is modified with each major release.
*/
// to avoid constant folding by the compiler, this field must *not* be final
public static String REQUESTED_API_VERSION = "1.6.99"; // !final
private static final String loggerFactoryClassStr = AndroidLoggerFactory.class.getName();
/**
* The ILoggerFactory instance returned by the {@link #getLoggerFactory} method
* should always be the same object
*/
private final ILoggerFactory loggerFactory;
private StaticLoggerBinder() {
loggerFactory = new AndroidLoggerFactory();
}
public ILoggerFactory getLoggerFactory() {
return loggerFactory;
}
public String getLoggerFactoryClassStr() {
return loggerFactoryClassStr;
}
}

View File

@ -0,0 +1,67 @@
/**
* Copyright (c) 2004-2013 QOS.ch
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
package org.slf4j.impl;
import org.slf4j.helpers.NOPMDCAdapter;
import org.slf4j.spi.MDCAdapter;
/**
* This implementation is bound to {@link NOPMDCAdapter}.
*
* @author Ceki G&uuml;lc&uuml;
* @author Andrey Korzhevskiy <a.korzhevskiy@gmail.com>
*/
public class StaticMDCBinder {
/**
* The unique instance of this class.
*/
public static final StaticMDCBinder SINGLETON = new StaticMDCBinder();
private StaticMDCBinder() {
}
/**
* Return the singleton of this class.
*
* @return the StaticMDCBinder singleton
* @since 1.7.14
*/
public static final StaticMDCBinder getSingleton() {
return SINGLETON;
}
/**
* Currently this method always returns an instance of
* {@link NOPMDCAdapter}.
*/
public MDCAdapter getMDCA() {
return new NOPMDCAdapter();
}
public String getMDCAdapterClassStr() {
return NOPMDCAdapter.class.getName();
}
}

View File

@ -0,0 +1,77 @@
/**
* Copyright (c) 2004-2013 QOS.ch
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
package org.slf4j.impl;
import org.slf4j.IMarkerFactory;
import org.slf4j.MarkerFactory;
import org.slf4j.helpers.BasicMarkerFactory;
import org.slf4j.spi.MarkerFactoryBinder;
/**
*
* The binding of {@link MarkerFactory} class with an actual instance of
* {@link IMarkerFactory} is performed using information returned by this class.
*
* @author Ceki G&uuml;lc&uuml;
* @author Andrey Korzhevskiy <a.korzhevskiy@gmail.com>
*/
public class StaticMarkerBinder implements MarkerFactoryBinder {
/**
* The unique instance of this class.
*/
public static final StaticMarkerBinder SINGLETON = new StaticMarkerBinder();
final IMarkerFactory markerFactory = new BasicMarkerFactory();
private StaticMarkerBinder() {
}
/**
* Return the singleton of this class.
*
* @return the StaticMarkerBinder singleton
* @since 1.7.14
*/
public static StaticMarkerBinder getSingleton() {
return SINGLETON;
}
/**
* Currently this method always returns an instance of
* {@link BasicMarkerFactory}.
*/
public IMarkerFactory getMarkerFactory() {
return markerFactory;
}
/**
* Currently, this method returns the class name of
* {@link BasicMarkerFactory}.
*/
public String getMarkerFactoryClassStr() {
return BasicMarkerFactory.class.getName();
}
}

Some files were not shown because too many files have changed in this diff Show More