Compare commits

..

407 Commits

Author SHA1 Message Date
ceki 61400453cd start work on 2.0.19-SNAPSHOT
Signed-off-by: ceki <ceki@qos.ch>
2026-05-12 20:37:36 +02:00
ceki 58b66c2c7e update central-publishing-maven-plugin
Signed-off-by: ceki <ceki@qos.ch>
2026-05-12 20:32:21 +02:00
ceki be4841cce8 prepare release 2.0.18
Signed-off-by: ceki <ceki@qos.ch>
2026-05-12 20:15:59 +02:00
ceki d2073bece8 minor refactoring, javadoc changes
Signed-off-by: ceki <ceki@qos.ch>
2025-11-24 17:51:51 +01:00
ceki 32a9854cf4 add a trivial test for CONFIG_PARAMS.warnLevelString
Signed-off-by: ceki <ceki@qos.ch>
2025-11-03 15:24:43 +01:00
ceki 77936c6f1f CONFIG_PARAMS.warnLevelString should be taken into account
See https://github.com/qos-ch/slf4j/issues/471

Signed-off-by: ceki <ceki@qos.ch>
2025-11-03 14:31:01 +01:00
ceki 34c9d30af5 extract first marker when caller locationAwareLogger
Signed-off-by: ceki <ceki@qos.ch>
2025-11-01 20:09:13 +01:00
ceki 902b463957 remove cruft
Signed-off-by: ceki <ceki@qos.ch>
2025-10-01 16:00:03 +02:00
ceki b3c2f16f12 security manager is no longer supported in later JDKs
Signed-off-by: ceki <ceki@qos.ch>
2025-10-01 15:59:29 +02:00
ceki 9468c7a28f remove unneccessary and unused files
Signed-off-by: ceki <ceki@qos.ch>
2025-10-01 15:58:52 +02:00
Ceki Gulcu 183aaa5070 start work on 2.0.18-SNAPSHOT
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2025-02-25 18:40:43 +01:00
Ceki Gulcu c233ea1932 prepare release 2.0.17
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2025-02-25 17:36:36 +01:00
Ceki Gulcu 4b4d533771 In SLF4JProviders, move initialization of the markerFactory and
mdcAdapter fields to the constructor.

Added comments regarding LoggerFactory expectation of providers to
initialize their MDCAdapter and markerFactory field as early as
possible, preferably at construction time.

Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2025-02-07 10:36:45 +01:00
Ceki Gulcu 9349d64f95 In response to issue 450, moved the binding of the MDCAdapter in the
MDC class from the static initializer to the LoggerFactory.bind method.

In case MDC methods are called before LoggerFactory, the various methods
in MDC have been modified to go through the getMDCAdapter method which
checks for this rare case.

https://github.com/qos-ch/slf4j/issues/450

Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2025-02-07 10:05:06 +01:00
Piotr P. Karwasz 0def25ebfa Replace license names with SPDX identifiers
As suggested by [Maven documentation](https://maven.apache.org/pom.html#Licenses) the `/project/licenses/licence/name` element in the POM file should contain a SPDX identifier of the license.
The license element is often used by external tools, such as SBOM generators.

This PR:

- Replaces the current content of the `<name>` element with the appropriate SPDX identifier.
- Follows all HTTP 301 redirections of the currently provided license URLs.

Signed-off-by: Piotr P. Karwasz <piotr.github@karwasz.org>
2024-12-10 11:01:56 +01:00
Ceki Gulcu 69c333de28 fix issues/425
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2024-10-21 20:50:59 +02:00
Ceki Gülcü 2470fad4fd
Update README.md 2024-09-22 11:14:48 +02:00
Ceki Gülcü c2c29fec98
Update README.md 2024-09-22 11:12:06 +02:00
Ceki Gulcu 0597225b5b README updates
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2024-09-22 11:07:14 +02:00
Ceki Gulcu f7b34c2e60 fix incorrect interpretation of Level.OFF and Level.ALL in SLF4JPlatformLogger
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2024-09-21 13:16:33 +02:00
Ceki Gulcu 4fa92fc007 start work on 2.0.17-SNAPSHOT
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2024-08-10 11:38:41 +02:00
Ceki Gulcu 101086ba35 prepare release 2.0.16
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2024-08-10 11:11:51 +02:00
Ceki Gulcu 8ae0efca23 class.getModule is new in Java9
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2024-08-10 11:00:18 +02:00
Ceki Gulcu 3ff00870b3 print connected provider only if DEBUG level for internal reporting is enabled
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2024-08-10 09:49:56 +02:00
Manfred Hanke 0df43e9e53 fix javadoc of Slf4jEnvUtil
resolves #423

Signed-off-by: Manfred Hanke <Manfred.Hanke@tngtech.com>
2024-08-08 22:24:18 +02:00
Ceki Gulcu 46b5ea54a6 start work on 2.0.16-SNAPSHOT
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2024-08-08 16:48:10 +02:00
Ceki Gulcu 5321a975d4 prepare release 2.0.15
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2024-08-08 14:56:10 +02:00
Ceki Gulcu 09111e8c1e added copyright, @since to Slf4jEnvUtil
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2024-08-07 17:46:14 +02:00
Ceki Gulcu 6a04f67fdd start work on version 2.0.15-SNAPSHOT
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2024-08-07 17:31:29 +02:00
Ceki Gulcu 03aa6b915a prepare release 2.0.14
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2024-08-06 22:30:45 +02:00
Ceki Gulcu 7c3b0ef011 added method returning slf4j version
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2024-08-06 22:17:49 +02:00
Ceki Gulcu 42810107b0 LoggerFactory emits 'SLF4J(I): Connected with provider of type'
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2024-08-05 22:10:08 +02:00
Ceki Gulcu 982e4b067f clearer assertion take II
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2024-08-04 21:30:31 +02:00
Ceki Gulcu dd4486b5c5 clearer assertion
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2024-08-04 21:25:43 +02:00
Ceki Gulcu 1d82519b07 start work on 2.0.14-SNAPSHOT
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2024-04-12 18:05:28 +02:00
Ceki Gulcu 5ffbc67def prepare release 2.0.13
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2024-04-12 16:21:00 +02:00
Ceki Gulcu 3386517ad6 fix issues/409 SLF4J-601, wrong classname when using slf4j inside a wrapper
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2024-04-12 15:47:48 +02:00
Ceki Gulcu 448bca173c start work on 2.0.13-SNAPSHOT
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2024-02-05 22:58:12 +01:00
Ceki Gulcu 955209464d increase leniency count
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2024-02-05 22:32:22 +01:00
Ceki Gulcu c1473c957a prepare release 2.0.12
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2024-02-05 22:21:34 +01:00
Ceki Gulcu 98932348fb minor reminder
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2024-02-05 22:20:48 +01:00
Ceki Gulcu c52da92599 revert Util.report methods removed by mistake
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2024-02-05 22:17:54 +01:00
Ceki Gulcu da91e4f219 export provider packages, allow reflection by org.slf4j
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2024-02-05 21:45:58 +01:00
Ceki Gulcu 8c4ea8f225 more comments
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2024-01-23 15:51:31 +01:00
Ceki Gulcu 6b2921a523 start wotk on 2.0.12-SNAPSHOT
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2024-01-08 20:50:02 +01:00
Ceki Gulcu 3f4717c44e get javadoc:aggregate command to work
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2024-01-08 20:48:59 +01:00
Ceki Gulcu d9145fba56 prepare release 2.0.11
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2024-01-08 18:58:10 +01:00
Ceki Gulcu 68ff7064ec acceptance test, disabled for the moment
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2024-01-08 18:50:54 +01:00
Guillaume Nodet db8cd90c10 Use computeIfAbsent with a protected method, make reset protected
Signed-off-by: Guillaume Nodet <gnodet@gmail.com>
2024-01-08 17:39:25 +01:00
Guillaume Nodet d564304a61 Use computeIfAbsent with a protected method, make reset protected
Signed-off-by: Guillaume Nodet <gnodet@gmail.com>
2024-01-08 17:39:25 +01:00
Ceki Gulcu ef8dda71dd javadoc changed for SimpleLogger constructor
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2024-01-08 15:23:23 +01:00
Ceki Gulcu fe42ecb5f7 change constructor access modifier instead of
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2024-01-08 15:16:08 +01:00
Ceki Gulcu 7029a8b7fd add renderLevel method in SimpleLogger
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2024-01-08 15:02:22 +01:00
Ceki Gulcu 8c873b2e75 start work on 2.0.11-SNAPSHOT
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2023-12-29 00:03:40 +01:00
Ceki Gulcu 7bcee9aa1f javadoc configuration tweak
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2023-12-29 00:02:38 +01:00
Ceki Gulcu 6fe9c07113 more javadoc adjustments
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2023-12-28 21:48:34 +01:00
Ceki Gulcu df562c22d8 migrator should have javadocs
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2023-12-28 21:38:38 +01:00
Ceki Gulcu 6d39ca8bf9 prepare release 2.0.10
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2023-12-28 21:14:08 +01:00
Ceki Gulcu 86ee8298d9 javadoc edit
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2023-12-06 20:54:40 +01:00
Ceki Gulcu 5ccbe20b11 remove unreachable code, see issues/371
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2023-12-05 10:02:43 +01:00
Ceki Gulcu 02b36a269a attempt at fixing PR 358
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2023-11-25 20:47:16 +01:00
Ceki Gulcu c12667b906 document Reporter class
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2023-11-17 12:57:30 +01:00
Ceki Gulcu 316b5d1727 first attempt at fixing issues/361
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2023-11-15 19:59:01 +01:00
Hervé Boutemy 7c164fab8d upgrade maven-bundle-plugin
fixes Reproducible  Builds issue with OSGi metadata
2023-09-03 23:03:40 +02:00
Ceki Gulcu 56e42fdb61 start work on 2.0.10-SNAPSHOT
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2023-09-03 18:20:34 +02:00
Ceki Gulcu 216459e5d8 prepare release 2.0.9
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2023-09-03 18:12:02 +02:00
Ceki Gulcu 2481810f94 rename slf4j.binding system proerty as slf4j.provider
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2023-09-03 18:06:27 +02:00
Ceki Gulcu 25d742d666 start work on 2.0.9-SNAPSHOT
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2023-09-03 17:44:47 +02:00
Ceki Gulcu 10a151756d further adjusments for successful deployment on Maven Central
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2023-08-29 23:31:08 +02:00
Ceki Gulcu 17f5bf3d87 fix issues during deployment
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2023-08-29 23:04:24 +02:00
Ceki Gulcu f967033766 move parent-pom.xml to parent/pom.xml as explained in SLF4J-437
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2023-08-29 22:50:25 +02:00
Ceki Gulcu 0b9c92cc3a prepare release 2.0.8
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2023-08-29 22:14:17 +02:00
Ceki Gulcu 05698f8d23 fine tuning for SLF4J-450
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2023-08-29 22:06:48 +02:00
Kengo TODA 9783320b6c feat: allow binding to be explicitly specified 2023-08-29 16:40:18 +02:00
Ethan McCue aa13da39ed Fix typo in "SLF4JPlarformLoggerFactory"
Signed-off-by: Ethan McCue <ethan@mccue.dev>
2023-08-08 18:25:20 +02:00
Ceki Gulcu 7a4da876b3 add equals/hashCode to KeyValuePair
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2023-08-08 18:20:12 +02:00
Taku Miyakawa 0769bc8182 use MessageFormat insetad of String.format to comply spec of System.Logger.log
Signed-off-by: Taku Miyakawa <miyakawa.taku@gmail.com>
2023-08-08 18:12:15 +02:00
Ceki Gulcu e63f87f02c fix SLF4J-595
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2023-07-12 22:50:26 +02:00
Ceki Gulcu 3f20e0dfd2 update certain plugins, add parent-pom.xml as a module fixing SLF4J-596
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2023-07-12 21:52:15 +02:00
Ceki Gulcu 06fa09a2fb use jar plugin to add MainClass information in MANIFEST.MF instead of the fleix plugin, see SLF4J-594
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2023-07-11 11:04:41 +02:00
Ceki Gulcu 6fd9db9b5e add BOM file, fixes SLF4J-437
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2023-06-16 18:05:17 +02:00
Hannes Wellmann f871e7f2e9 Restore 'Main-Class' header in slf4j-migrator Manifest.MF
Because the Manifest.MF did not have a terminating new-line it was
invalid and its content was ignored, thus the Main-Class entry was
missing.

To have less files in the project, generate the entry using the
maven-bundle-plugin.

Signed-off-by: Hannes Wellmann <wellmann.hannes1@gmx.net>
2023-04-10 00:13:24 +02:00
Hannes Wellmann 0b4d88edef Use project.name in Bundle-Name and simplify slf4j-api OSGi metadata gen
The value of project.name is more expressive than the previously used
project.artifactId.

Signed-off-by: Hannes Wellmann <wellmann.hannes1@gmx.net>
2023-04-10 00:11:41 +02:00
Hannes Wellmann 2ec7c1034c Replace all remaining OSGi MANIFEST.MF by bundle-plugin instructions
This ensures that there is only a single source for OSGi metadata.
Additionally this improves the metadata for some Export-Package entries.

Signed-off-by: Hannes Wellmann <wellmann.hannes1@gmx.net>
2023-04-10 00:11:41 +02:00
Hannes Wellmann df44ace9c3 Automate OSGi metadata creation and fix metadata for other slf4j-modules
Only use the maven-bundle-plugin to generate all OSGi metadata into
slf4j's Manifest.MF files. This unifies the resulting MANIFEST.MFs
that are currently partly generated and partly statically defined and
fixes the following aspects:

- Fix the package-export of slf4j-jdk-platform-logging (from
'slf4j.jdk.platform.logging' to 'org.slf4j.jdk.platform.logging')
- Import missing packages for slf4j-reload4j and log4j-over-slf4j
- Replace the deprecated 'Bundle-RequiredExecutionEnvironment' by a
corresponding required 'osgi.ee' capability
- Restores the exported packages of jcl-over-slf4j

Fixes https://jira.qos.ch/browse/SLF4J-578

Signed-off-by: Hannes Wellmann <wellmann.hannes1@gmx.net>
2023-04-10 00:11:41 +02:00
Hannes Wellmann 661869eeb2 Adapt project names from 'Binding' to 'Provider'
Since slf4j 2 Bindings are now called Providers. The corresponding Maven
project names and descriptions should be adapted accordingly.

Signed-off-by: Hannes Wellmann <wellmann.hannes1@gmx.net>
2023-04-09 18:25:43 +02:00
Ceki Gulcu cff3312e43 start work on 2.0.8-SNAPSHOT
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2023-03-17 20:41:07 +01:00
Ceki Gulcu d6a21ae68f update javadoc plugin to version 3.0.5
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2023-03-17 20:35:35 +01:00
Ceki Gulcu 13950e51a6 prepare release 2.0.7
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2023-03-17 19:49:13 +01:00
Ceki Gulcu 122e0c18dd add LICENSE.txt files to all modules, rename LICENSE as LICENSE.txt when appropriate
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2023-03-17 19:35:56 +01:00
TWI 2a8ca99caf add license file to jar 2023-03-17 19:25:44 +01:00
Hannes Wellmann b363bb31ed SLF4J-579: Export client packages of slf4j-api in version 1
Fixes https://jira.qos.ch/browse/SLF4J-576

This allows to use the slf4j-api version 2 artifact as drop-in
replacement for slf4j-api version 1 in OSGi environments as well.
slf4j-api can now be wired to bundles that require packages of slf4j-api
in version 1 or 2.

Signed-off-by: Hannes Wellmann <wellmann.hannes1@gmx.net>
2023-03-17 18:01:31 +01:00
Hannes Wellmann 2235d3c698
Fully automate OSGi metadata creation and fix brocken OSGi-metadata in slf4j-api (#330)
* Improve generated OSGi metadata and restore Bundle-SymbolicName

Enhance the generated OSGi metadata for all slf4j-modules in the
following ways:
- Restore the Bundle-SymbolicName, Bundle-Name, Bundle-Vendor and
Bundle-DocURL from SLF4J-2.0.5 and before
- Removes Export-Package: META-INF.versions.9
- Removes self-Imports of exported package (has to be added again in a
follow up, where desired)
- Remove unnecessary BND-internal headers

Additionally move the maven-bundle-plugin configuration from the
execution configuration up into the configuration of the plugin so that
it can be easier overwritten in child-modules.

Signed-off-by: Hannes Wellmann <wellmann.hannes1@gmx.net>

* Automate OSGi metadata creation and restore package-exports of slf4j-api

Only use the maven-bundle-plugin to generate all OSGi metadata into
slf4j-api's Manifest.MF file. This unifies the resulting MANIFEST.MFs
that are currently partly generated and partly statically defined.

Furthermore it fixes the following flaws in the currently generated OSGi
metadata of slf4j-api:
- Import only the exported org.slf4j.spi package (like in slf4j 2.0.5
and before)
- Replace the deprecated 'Bundle-RequiredExecutionEnvironment' header by
a corresponding required 'osgi.ee' capability

Signed-off-by: Hannes Wellmann <wellmann.hannes1@gmx.net>

---------

Signed-off-by: Hannes Wellmann <wellmann.hannes1@gmx.net>
2023-03-15 21:28:25 +01:00
Sean C. Sullivan a5540ad510 setup-java v3
Signed-off-by: Sean C. Sullivan <github@seansullivan.com>
2022-12-19 20:40:13 +01:00
Ceki Gulcu 1ed084cbc0 add missing distribution instruction to github action
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-12-19 20:25:11 +01:00
Ceki Gulcu b2cb017422 update github action versions
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-12-19 20:21:52 +01:00
Sean C. Sullivan fa6721a53e add JDK 19 to CI build
Signed-off-by: Sean C. Sullivan <github@seansullivan.com>
2022-12-19 20:19:54 +01:00
Ceki Gulcu f85104040c start work on 2.0.7-SNAPSHOT
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-12-12 20:19:53 +01:00
Ceki Gulcu 5ff6f2c385 prepare for release 2.0.6
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-12-12 20:11:11 +01:00
Ceki Gulcu 2f4aa75445 fix SLF4J-575
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-12-10 19:30:48 +01:00
Ceki Gulcu 363f0a534e remove unused parts
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-12-10 00:38:56 +01:00
Jonah Graham 171679baa8 SLF4J-574: Add full OSGi headers, especially "uses" clauses
Fixes: https://jira.qos.ch/browse/SLF4J-574

This uses the BND tool, via org.apache.felix to generate
the MANIFEST.MF to be fully compliant with OSGi.
Compared to using just the maven-jar-plugin to create
the MANIFEST.MF the uses clauses are added to the
Export-Package

Signed-off-by: Jonah Graham <jonah@kichwacoders.com>
2022-12-10 00:10:39 +01:00
Ceki Gulcu 921b5b31e1 fix FUNDING file
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-12-09 13:31:52 +01:00
Ceki Gulcu e02244c39f fix FUNDING file
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-12-09 13:31:16 +01:00
Ceki Gulcu 441d4584be fix FUNDING file
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-12-09 13:30:56 +01:00
Ceki Gulcu f5e741ba1a add FUNDING file
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-12-09 13:30:01 +01:00
Ceki Gulcu 2e71327c8e remove unused log4j dependency in the version definition section of pom.xml
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-11-26 20:43:43 +01:00
Ceki Gulcu 3ff2a30e05 start work on 2.0.6-SNAPSHOT
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-11-25 13:33:29 +01:00
Ceki Gulcu 7e62e1e691 prepare release 2.0.5
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-11-25 12:40:18 +01:00
Ceki Gulcu d250ad79eb in jcl-over-slf4j rename LICENSE.TXT as LICENSE, add LICENSE file to log4j-over-slf4j
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-11-25 09:56:46 +01:00
Ceki Gulcu 3bc58f3e81 add SecurityManager support
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-11-24 20:12:00 +01:00
Ceki Gulcu 207bb299c3 start work on 2.0.5-SNAPSHOT
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-11-17 21:38:06 +01:00
Ceki Gulcu 35dd7ff1e7 removed unused META-INF/services entry
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-11-17 21:25:09 +01:00
Ceki Gulcu 440c2f3000 prepare release 2.0.4
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-11-17 21:04:44 +01:00
Ceki Gulcu 43a36303e5 use the class loader that loaded LoggerFactory (instead of the threadContextClassLoader) to find providers
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-11-17 20:49:29 +01:00
Piotr P. Karwasz 557bf7c0bd [SLF4J-548] Fix ServiceLoader usage in servlet environment
If both the servlet container and a web application use SLF4J,
`ServiceLoader` calls are susceptible to three problems:

1. The SLF4J copy in the webapp detects the common providers by can not
instantiate them (they implement a different copy of
`SLF4JProviderService`),
2. The SLF4J copy in the common classloader can bind the providers in
the webapp classloader and cause a memory leak,
3. If the server uses a SecurityManager the static initialization of
`LoggerFactory` fails if called by unprivileged code.

This PR should solve these problems.

Signed-off-by: Piotr P. Karwasz <piotr.github@karwasz.org>
2022-11-17 19:28:19 +01:00
Stefan Bischof 632410565b enhance manifest with capabilities
provide for SLF4JServiceProvider (with name attribute
require for registrar

Signed-off-by: Stefan Bischof <stbischof@bipolis.org>
2022-11-14 18:30:33 +01:00
Ceki Gulcu e540299d58 edit blurb on release championing 2022-10-11 21:18:58 +02:00
Ceki Gülcü dfb41b06a8
Update README.md 2022-10-11 21:04:18 +02:00
Ceki Gulcu 47c7cc7fa4 clarify Logger.makeLoggingEventBuilder javadoc
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-09-28 15:25:09 +02:00
Ceki Gulcu 0be1bc15f2 Merge branch 'master' of github.com:qos-ch/slf4j 2022-09-28 15:24:06 +02:00
Ceki Gülcü d60690c0b9
more flexible way to 2022-09-28 15:23:30 +02:00
Ceki Gülcü 6720d8db66
Update README.md 2022-09-28 15:10:51 +02:00
Ceki Gülcü 72a0bc6528
Update README.md 2022-09-28 15:04:47 +02:00
Ceki Gülcü f276d52d96
Update README.md 2022-09-28 15:04:20 +02:00
Ceki Gulcu 7cad6082dc Merge branch 'master' of github.com:qos-ch/slf4j 2022-09-28 13:44:04 +02:00
Kengo TODA 143978ce05 annotates new methods to help static analysis tools
Signed-off-by: Kengo TODA <skypencil@gmail.com>
2022-09-28 13:43:36 +02:00
Ceki Gulcu 88b0ee3c1f start work on 2.0.4-SNAPSHOT
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-09-28 13:30:20 +02:00
Ceki Gulcu b2cb05f16a prepare release 2.0.3
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-09-28 12:15:18 +02:00
Ceki Gulcu 4b5bb41ede fix SLF4J-546, Fluent logging API doesn't populate timestamp with Reload4JLogger
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-09-28 12:05:26 +02:00
Ceki Gulcu b500a6fdfd javadoc explaining using multiple markers instead of nested markers
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-09-26 19:58:49 +02:00
Ceki Gulcu d81affb012 comment about ThreadLocal key or value types
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-09-26 19:57:31 +02:00
Ashley Scopes bcbbe40ffd Reword Marker Javadoc to improve grammar.
Signed-off-by: Ashley Scopes <73482956+ascopes@users.noreply.github.com>
2022-09-25 16:05:27 +02:00
Ceki Gülcü 7686020c36
Merge pull request #310 from ascopes/patch-1
Add missing javadoc to SLF4JServiceProvider.java
2022-09-25 16:02:33 +02:00
Ashley Scopes 3f47f87ccc Add missing javadoc to SLF4JServiceProvider.java
Had to do some digging around the logback-classic alpha release for SLF4J2 API
integration to work out the nature of this behaviour. This should prevent confusion
for developers of other logging implementations in the future.

Signed-off-by: Ashley Scopes <73482956+ascopes@users.noreply.github.com>
2022-09-25 14:49:03 +01:00
Ceki Gulcu eb1710af7b start work on 2.0.3-SNAPSHOT, fix SLF4J-564 2022-09-21 23:17:52 +02:00
Ceki Gülcü bb49a5aeef
Merge pull request #307 from radio-rogal/slf4j-564-simple-logger-javadoc
[SLF4J-564] slf4j-simple: fix javadoc for SimpleLogger
2022-09-21 23:03:25 +02:00
Witalij Berdinskich 768ca7d4c0 [SLF4J-564] slf4j-simple: fix javadoc for SimpleLogger
Signed-off-by: Witalij Berdinskich <radio_rogal@keemail.me>
2022-09-21 22:40:56 +03:00
Ceki Gulcu 0645c18caf prepare release 2.0.2
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-09-20 21:36:11 +02:00
Ceki Gulcu 894b1890a0 fix SLF4J-563
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-09-20 20:44:05 +02:00
Ceki Gulcu 7c1d86e21e start work on 2.0.2-SNAPSHOT
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-09-14 16:48:41 +02:00
Ceki Gulcu 9752442b6e prepare release 2.0.1
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-09-14 16:27:30 +02:00
Ceki Gulcu c0f7f16bfb minor javadoc change
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-09-14 16:06:16 +02:00
Ceki Gulcu 1148b98529 Merge branch 'master' of github.com:qos-ch/slf4j 2022-09-14 15:39:58 +02:00
Ceki Gulcu 593f89f85a fix SLF4J SLF4J-560
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-09-14 15:39:40 +02:00
Ceki Gülcü 03deea9f77
Merge pull request #302 from coheigea/coheigea/reload4j_1.2.22
Update reload4j to 1.2.22
2022-08-29 09:40:18 +02:00
Colm O hEigeartaigh c9d5cc1257
Update reload4j to 1.2.22 2022-08-29 08:02:12 +01:00
Ceki Gülcü bae56f544b
Merge pull request #294 from marcwrobel/fix-typos
fix typos in documentations
2022-08-25 21:35:07 +02:00
Marc Wrobel 24788ac731
fix typos in documentations
Fix typos in javadoc, comments and README.

Signed-off-by: Marc Wrobel <marc.wrobel@gmail.com>
2022-08-25 20:48:13 +02:00
Ceki Gulcu 05c0b0a881 fix SLF4J-555
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-08-23 22:42:13 +02:00
Ceki Gulcu 400a885e7d remove reference to 1.7
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-08-22 17:50:40 +02:00
Ceki Gulcu a4f165689f use https links
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-08-22 16:36:38 +02:00
Ceki Gulcu 4685f1ebc0 add reminder in release.sh
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-08-22 15:01:50 +02:00
Ceki Gulcu 15d4c1fdd6 fix path to codes.html
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-08-22 15:01:17 +02:00
Ceki Gulcu 42f863863f upodate gpg key information
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-08-20 21:56:31 +02:00
Ceki Gulcu 51ceaf6224 start work on 2.0.1-SNAPSHOT
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-08-20 21:31:19 +02:00
Ceki Gulcu 0614d467d7 prepare release 2.0.0
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-08-20 21:04:05 +02:00
Ceki Gulcu b1afcd01b1 javadoc edits
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-08-07 00:04:53 +02:00
Ceki Gulcu 20cd3ad0ab start work on 2.0.0-SNAPSHOT
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-08-07 00:04:28 +02:00
Ceki Gulcu aeebb6199d prepare release 2.0.0-beta1
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-08-06 23:31:54 +02:00
Ceki Gulcu 1068cd0eb9 javadoc changes
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-08-06 23:25:49 +02:00
Ceki Gulcu 4e4e56a2df add CheckReturnValue annotation in org.slf4j.helpers
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-08-06 22:44:44 +02:00
Ceki Gulcu 0dcfa19040 check for return value in some oggingEventBuilder methods
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-08-06 22:03:35 +02:00
Ceki Gulcu e7ca8d17c8 start work on 2.0.0-beta1-SNAPSHOPT
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-08-06 21:26:09 +02:00
Ceki Gulcu 2314de9dd9 add setMessage and log method to the fluent API
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-08-05 22:46:46 +02:00
Ceki Gulcu 508a796552 set version to 2.0.0-beta0
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-08-05 22:00:48 +02:00
Ceki Gulcu d93a5e0456 minor javadoc changes
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-07-21 12:46:38 +02:00
Ceki Gülcü 43005d1d85
Merge pull request #293 from varunsh-coder/token-perms
ci: add GitHub token permissions for workflow
2022-07-21 12:42:02 +02:00
Varun Sharma 14ec670971 ci: add GitHub token permissions for workflow
Signed-off-by: Varun Sharma <varunsh@stepsecurity.io>
2022-07-10 07:17:58 -07:00
Ceki Gulcu c0001d4619 remove slf4j-site
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-06-15 20:31:10 +02:00
Ceki Gulcu 9feda2c795 remove slf4j-site
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-06-15 20:30:49 +02:00
Ceki Gulcu 287fe4f97a add closing double quote
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-06-14 17:01:39 +02:00
Ceki Gülcü 5537ff1699
Merge pull request #290 from ckbisk/patch-1
SLF4J-551: fix broken org/org Log4j link in left.js
2022-06-08 15:38:16 +02:00
Chad K Bisk 996866fae7
fix broken org/org Log4j link in left.js
https://jira.qos.ch/browse/SLF4J-551
2022-06-07 23:30:06 -04:00
Ceki Gulcu ae032b1297 remove infra information
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-05-27 17:50:14 +02:00
Ceki Gulcu 6afe5ab7a7 gpg password on a dedicated panel
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-05-27 17:34:30 +02:00
Ceki Gulcu 82a592ed79 info about keystore
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-05-17 18:49:07 +02:00
Ceki Gulcu e454d28282 deny history overwrite
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-05-11 12:02:06 +02:00
Ceki Gulcu db3835d392 add SECURITY.md
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-05-11 11:49:52 +02:00
Ceki Gulcu 61574d22f4 discussion header
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-05-11 10:47:13 +02:00
Ceki Gulcu 9dd3de0511 fix name of variable
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-05-05 20:36:48 +02:00
Ceki Gülcü 6701960a59
Merge pull request #287 from srt4/bugfix/SLF4J-549-update-event-recoding-logger-name
Update EventRecodingLogger name to EventRecordingLogger (SLF4J-549)
2022-05-05 19:43:00 +02:00
Spencer Thomas 98728180ac Update EventRecodingLogger name to EventRecordingLogger (SLF4J-549)
Signed-off-by: Spencer Thomas <srt4@uw.edu>
2022-05-05 10:20:39 -07:00
Ceki Gülcü ac854c79ea
Merge pull request #282 from tenghuanhe/patch-2
Fix minor typos in README.md
2022-04-14 18:42:02 +02:00
Tenghuan He 0c0eb1275d Fix minor typos in README.md
Signed-off-by: tenghuanhe <tenghuanhe@gmail.com>
2022-04-15 00:24:05 +08:00
Ceki Gülcü 2b0e15874a
Merge pull request #249 from gnp/master
Fix typo: "apllications" --> "applications"
2022-04-05 20:10:11 +02:00
Ceki Gülcü 045f502fa9
Merge pull request #281 from josephw/typo-in-reload4j-logger-adapter-variable-name
Fix typo abbreviation for fully-qualified class name.
2022-04-02 21:56:18 +02:00
Joseph Walton a188a3ed73 Fix typo abbreviation for fully-qualified class name.
Signed-off-by: Joseph Walton <joe@kafsemo.org>
2022-04-01 22:02:23 +11:00
Ceki Gulcu 23182d4468 delete unused import
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-03-30 20:36:13 +02:00
Ceki Gulcu aa0de34dc6 start work on 2.0.0-alpha8
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-03-17 20:45:02 +01:00
Ceki Gulcu 5c4fe1d48c minor edits
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-03-17 20:40:33 +01:00
Ceki Gulcu 90f3f1ea07 update news about release 2.0.0-alpha7
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-03-17 20:34:10 +01:00
Ceki Gulcu 5fcbb283a3 slf4j-log4j12 relocated, prepare release 2.0.0-alpha7
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-03-17 18:38:36 +01:00
Ceki Gulcu 956acb06d6 add info about version99.qos.ch going away at the end of the year
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-03-17 17:03:38 +01:00
Ceki Gulcu 6df6053c24 caller data extraction support - SLF4J-511
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-03-09 23:08:54 +01:00
Ceki Gulcu 74ccf20fab typo fixes
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-02-28 21:23:39 +01:00
Ceki Gulcu 8806a45ede doc edits
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-02-18 11:22:44 +01:00
Ceki Gulcu 2287768293 fix SLF4J-541
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-02-08 14:39:04 +01:00
Ceki Gulcu bef80280e6 add sponsorship request to header
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-01-26 20:50:23 +01:00
Ceki Gulcu c1282ba08c update stable versions
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-01-25 15:39:50 +01:00
Ceki Gulcu 81a0568d68 update docs
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-01-25 15:38:35 +01:00
Ceki Gulcu f04cf16b66 fix comments, less bragging
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-01-24 00:07:40 +01:00
Ceki Gulcu c69570fc51 mvn install seems to work better
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-01-17 23:37:27 +01:00
Ceki Gulcu 85541d5669 try maven package
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-01-17 23:33:05 +01:00
Ceki Gulcu 4835381767 try maven install
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-01-17 23:23:13 +01:00
Ceki Gulcu c9c5492ded add test in relation with LOGBACK-1612
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-01-17 22:21:52 +01:00
Ceki Gulcu 510cc99e37 try using JDK 11 and 17
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-01-17 22:20:13 +01:00
Ceki Gulcu a20a22299d github actions
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-01-17 22:17:23 +01:00
Ceki Gulcu 2d6b6344f0 doc edit
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-01-17 22:16:29 +01:00
Ceki Gulcu 16ab482cab added paragraph on JEP264, doc changes, minor refactoring
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-01-17 22:11:33 +01:00
Ceki Gulcu 39a07b9ce4 make VersionUtil more robust
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-01-14 16:42:33 +01:00
Ceki Gulcu 10bd70ca75 start work on 2.0.0-alpha7-SNAPSHOT
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-01-13 17:01:39 +01:00
Ceki Gulcu 66e9c2555f prepare release 2.0.0-alpa6
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-01-13 16:56:49 +01:00
Ceki Gulcu 28528094b9 mentioned reload4j in the docs
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-01-13 16:27:04 +01:00
Ceki Gulcu 6abaf6897b rename slf4j-reload4j classes
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-01-13 16:26:36 +01:00
Ceki Gulcu 39cf0fc837 fix SimpleLogger javadoc comment
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-01-13 16:25:23 +01:00
Ceki Gulcu 0e04efdbf6 add slf4j-reload4j module
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-01-13 15:21:26 +01:00
Ceki Gulcu 0d4167abe7 fix SLF4J-499
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-01-13 15:19:10 +01:00
ceki 60e70fbc83 Fix SLF4J-499 - log thread id in SimpleLogger 2022-01-13 11:55:50 +01:00
Ceki Gulcu 9e4a358634 Merge branch 'master' of github.com:qos-ch/slf4j 2022-01-12 22:43:15 +01:00
Ceki Gulcu f6076c1409 mention reload4j in log4Shell.html
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-01-12 22:42:52 +01:00
Ceki Gülcü 34547b2f32
Merge pull request #276 from japzio/japzio-patch-doc-typo
minor typo fix
2022-01-10 11:07:33 +01:00
Jasper C ea47492d7a typo
Signed-off-by: Jasper C <jculongit10@gmail.com>
2022-01-10 16:08:50 +08:00
Ceki Gulcu f09e33dd15 add support for keyed deques in MDC
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-01-05 22:11:03 +01:00
Ceki Gulcu 12b5a6b676 mvn compile in slf4j-site should copy images
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-01-05 22:09:59 +01:00
Ceki Gulcu 23c8cc0121 fix SubstitutableLoggerTest
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-01-05 22:09:05 +01:00
Ceki Gulcu 0877cb6410 add github sponsors link
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-01-04 18:32:23 +01:00
Ceki Gulcu 7144b50915 add FUNDING.yml file
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-01-04 15:03:13 +01:00
Ceki Gulcu 0e8713e1eb minor doc changes
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-01-02 23:30:41 +01:00
Ceki Gulcu 62a265d3c5 add keyedStack interface to MDC - SLF4J-531
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2022-01-02 23:26:23 +01:00
Ceki Gulcu 59100d75e1 add atLevel method to SubstituteLogger
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2021-12-24 11:39:21 +01:00
Ceki Gulcu b655c0a2b7 site updates
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2021-12-24 11:38:28 +01:00
Ceki Gulcu 6208cbbded site updates
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2021-12-24 11:37:18 +01:00
Ceki Gulcu 7c62cf8254 added atLevel method to Logger
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2021-12-16 18:25:14 +01:00
Ceki Gulcu c61f01783a added at() as an alias for makeLoggingEventBuilder()
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2021-12-16 00:56:42 +01:00
Ceki Gulcu ce15e71dd8 less drama 2021-12-15 08:51:26 +01:00
Ceki Gulcu c6ea154309 doc fixes
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2021-12-14 17:51:11 +01:00
Ceki Gulcu 2a9bcb15e0 doc fixes
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2021-12-14 17:17:33 +01:00
Ceki Gulcu 53a9833a3c read only access
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2021-12-13 20:16:44 +01:00
Ceki Gulcu 71d5c081e8 typo fixes
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2021-12-13 14:23:45 +01:00
Ceki Gulcu 81d57c271b doc changes
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2021-12-13 14:06:04 +01:00
Ceki Gulcu 65524de79a AS IS with no warranty
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2021-12-13 13:49:59 +01:00
Ceki Gulcu 45fbb1ebc8 css improvements
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2021-12-13 01:00:02 +01:00
Ceki Gulcu 7a68675fc6 updates to log4shell comments
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2021-12-12 00:39:53 +01:00
Ceki Gulcu 25ddfaaab0 comments on CVE-2021-44228
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2021-12-11 17:20:02 +01:00
Ceki Gulcu 98f1f2f465 fix typo in version name
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2021-09-27 23:23:14 +02:00
Ceki Gulcu cf09b2e34d Class.getPackageName is new to JDK 9
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2021-09-08 17:28:33 +02:00
Ceki Gulcu 1cea7b72e3 removed link to instructions for contributors
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2021-09-05 13:20:05 +02:00
Ceki Gulcu 50a68fe8cc tinkering with right.js
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2021-09-03 20:24:42 +02:00
Ceki Gulcu 6f0c54caa4 add jquery to pages
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2021-09-03 19:34:45 +02:00
Ceki Gulcu 590434e55f start work on 2.0.0-alpha6-SNAPSNOT 2021-08-30 21:38:21 +02:00
Ceki Gulcu 545755c2b7 bump junit version, remove unused repo reference 2021-08-30 21:36:34 +02:00
Ceki Gulcu 0a34a87495 preparing release of 2.0.0-alpha5
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2021-08-30 18:02:34 +02:00
Ceki Gulcu 252593b934 news update in relation with 2.0.0-alpha5
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2021-08-30 18:01:02 +02:00
Ceki Gulcu 43bcc961a2
Merge pull request #266 from dfa1/master
minor code cleanups
2021-08-30 17:05:50 +02:00
Ceki Gulcu f8bb0da47b
Merge branch 'master' into master 2021-08-30 17:05:18 +02:00
Ceki Gulcu 1d4535ad23 rename SLF4JPlarformLogger as SLF4JPlatformLogger
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2021-08-30 16:58:30 +02:00
Ceki Gulcu baadb61681 attempting to check for incorrect info META-INF/services/
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2021-08-30 15:11:36 +02:00
Ceki Gulcu 41b612d150 updates to faq
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2021-08-30 14:46:06 +02:00
Davide Angelocola 6e784e4ca3 minor code cleanups
- more private final fields
- avoiding C-style array declarations
- few typos, notably JPlarformLogger -> JPlatformLogger

Signed-off-by: Davide Angelocola <davide.angelocola@gmail.com>
2021-08-29 19:40:02 +02:00
Ceki Gulcu b977791f50
Merge pull request #265 from nipafx/patch-1
Fix platform logging service registration
2021-08-29 15:04:55 +02:00
Nicolai Parlog 4672a6fd52
Fix platform logging service registration
Related to #232 and SLF4J-442[1].

[1]: https://jira.qos.ch/browse/SLF4J-442
2021-08-29 11:23:57 +02:00
Ceki Gulcu d0836be06f
Merge pull request #264 from dfa1/master
upgrading code to Java 8
2021-08-27 01:16:43 +02:00
Davide Angelocola c7d79d86a9 upgrading code to Java 8
- for each
- diamond operator
- some typos

Signed-off-by: Davide Angelocola <davide.angelocola@gmail.com>
2021-08-25 19:52:31 +02:00
Ceki Gulcu 9bc0152371 doc changes
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2021-08-16 16:13:05 +02:00
Ceki Gulcu 21af69f3eb add travis build cache
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2021-08-16 16:12:45 +02:00
Ceki Gulcu 55357d2270 doc changes
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2021-08-15 10:09:12 +02:00
Ceki Gulcu 66aed4dfb1 javadoc fix
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2021-08-13 14:41:53 +02:00
Ceki Gulcu ccbd8f8c96 start work on 2.0.0-alpha5-SNAPSHOT
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2021-08-12 23:47:02 +02:00
Ceki Gulcu 7836be3be5 minor last minute fixes
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2021-08-12 23:20:04 +02:00
Ceki Gulcu c2e02170bb preparing 2.0.0-alpha4 release
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2021-08-12 22:34:32 +02:00
Ceki Gulcu e240abe9b1 testing caller info extraction with slf4j-jpl
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2021-08-12 22:28:39 +02:00
Ceki Gulcu eaa9fae39d ongoing work on the slf4j-jdk-platform-logging 2021-08-12 13:05:04 +02:00
Ceki Gulcu a42ad1f4f7 ongoing work on the slf4j-jdk-platform-logging module
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2021-08-11 17:09:18 +02:00
Ceki Gulcu e0448ad699 minor tweaks transparent to users
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2021-08-11 13:49:45 +02:00
Ceki Gulcu cc8e690ee8 initial version of PlatformLoggingTest
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2021-08-10 23:03:23 +02:00
Ceki Gulcu 4083b3dd0f Merge branch 'master' of github.com:qos-ch/slf4j
In relation with PR 232
2021-08-10 19:56:16 +02:00
Ceki Gulcu 1754a89208 start work on 2.0.0-alpha4-SNAPSHOT
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2021-08-10 19:54:16 +02:00
Ceki Gulcu d6c2ddbe89 latest stable is 1.7.32
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2021-08-10 19:54:16 +02:00
Ceki Gulcu 551283ba4c prepare release 2.0.0-alpha3
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2021-08-10 19:54:16 +02:00
Ceki Gulcu c0bacabab2 updated build-helper plugin version, removed lifecycle plugin
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2021-08-10 19:54:16 +02:00
Ceki Gulcu 2d3e9f7d2b release 2.0.0-alpha3 notes
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2021-08-10 19:54:16 +02:00
Ceki Gulcu e6d5d12c03 add toString method in KeyValuePair
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2021-08-10 19:54:16 +02:00
Ceki Gulcu 5958599ca9 make fields protected in DefaultLoggingEventBuilder
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2021-08-10 19:54:16 +02:00
Ceki Gulcu 66dda1a323 in DefaultLoggingEventBuilder renamde innerLog to log
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2021-08-10 19:54:16 +02:00
Ceki Gulcu 280129046e very minor changes
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2021-08-10 19:54:16 +02:00
Ceki Gulcu cf4d011ac0 simplify compilation directives
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2021-08-10 19:54:16 +02:00
Ceki Gulcu 8d5df5a41c move test to test packages
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2021-08-10 19:54:16 +02:00
Ceki Gulcu fc66b1fc68 correct path for NOPServiceProvider
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2021-08-10 19:54:16 +02:00
Ceki Gulcu 316e59084d rename org/slf4j/helpers/NOPServiceProvider as NOP_FallbackServiceProvider
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2021-08-10 19:54:16 +02:00
Ceki Gulcu 7483a11dd6 fix SLF4J-516
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2021-08-10 19:54:16 +02:00
Ceki Gulcu 47e751d63c make CONFIG_PARAMS aa final field
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2021-08-10 19:54:16 +02:00
Ceki Gulcu fb1929011f version should have a SNAPSHOT suffix at this stage
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2021-08-10 19:54:15 +02:00
Ceki Gulcu 5b3e70a353 align with changes in the 1.7 branch
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2021-08-10 19:54:15 +02:00
Ceki Gulcu 19d037f11a blurb about SLF4J-515
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2021-08-10 19:54:15 +02:00
Ceki Gulcu 75f6c0b2f9 fixing SLF4J-515
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2021-08-10 19:54:15 +02:00
Ceki Gulcu 5a0eba57e5 allow unit tests to run in a new thread
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2021-08-10 19:54:15 +02:00
Ceki Gulcu 3321b220b8 add info for verifying signed artifacts
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2021-08-10 19:54:15 +02:00
Ceki Gulcu b682787a2e start work on 2.0.0-alpha3
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2021-08-10 19:54:15 +02:00
Ceki Gulcu 252fbffede allow slf4j-site to build
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2021-08-10 19:54:15 +02:00
Ceki Gulcu 8601beed76 prepare release 2.0.0-alpha2
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2021-08-10 19:54:15 +02:00
Ceki Gulcu 8571f5d7f2 removing unused file
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2021-08-10 19:54:15 +02:00
Ceki Gulcu 62d6497f6a fix unit tests
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2021-08-10 19:54:15 +02:00
Ceki Gulcu b5446d67bb blurb on DCO
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2021-08-10 19:54:15 +02:00
Ceki Gulcu 8f602c309a testing sign-off hook
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2021-08-10 19:54:15 +02:00
Ceki Gulcu 04f3d418d1 testing sign-off hook 2021-08-10 19:54:15 +02:00
Ceki Gulcu 8859a8a019 edits
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2021-08-10 19:54:15 +02:00
Ceki Gulcu 0ae15e3981 document DCO requirement 2021-08-10 19:54:14 +02:00
Ceki Gulcu c233c86457 typo fixes and minor edits 2021-08-10 19:54:14 +02:00
Ceki Gulcu e74699276b Fix SLF4J-414 2021-08-10 19:54:14 +02:00
Ceki Gulcu 65eacb35a8 Fix SLF4J-421 and SLF4J-287 2021-08-10 19:54:14 +02:00
Ceki Gulcu 3e0016d8d1 add JMPS module names in FAQ (fixes SLF4J-465), other edits 2021-08-10 19:54:14 +02:00
Ceki Gulcu 601405b76f fix bugs detected by SubstituteLoggerTest 2021-08-10 19:54:14 +02:00
Ceki Gulcu 10d78b04d6 fix SLF4J-435 2021-08-10 19:54:14 +02:00
Ceki Gulcu 7547d1c871 add isEnabledForLevel method in Logger 2021-08-10 19:54:14 +02:00
Ceki Gulcu 45b177c2d2 make NOPLoggingEventBuilder constructor private and allow access via the singleton 2021-08-10 19:54:14 +02:00
Ceki Gulcu 730ee35665 removed unused NOPLogger, NOPLoggerFactory and NOPMDCAdapter from slf4j-nop module, these were moved to slf4j-a4j-ap-api module 2021-08-10 19:54:14 +02:00
Ceki Gulcu 3afcb8e8c4 formatting changes only. applied slf4j/codeStyle.xml in Eclipse 2021-08-10 19:54:14 +02:00
Ceki Gulcu 8a83b1bd34 cleaning up deprecated usage 2021-08-10 19:54:14 +02:00
Ceki Gulcu 4cd41f799d upgade plugin versions, clean up 2021-08-10 19:54:13 +02:00
Ceki Gulcu 9558b2103e the second -jar- goal is redundant 2021-08-10 19:54:13 +02:00
Ceki Gulcu a1683d9323 formatting changes only 2021-08-10 19:54:13 +02:00
Ceki Gulcu da6b46d8d7 stable version is 1.7.31 2021-08-10 19:54:13 +02:00
Ceki Gulcu 092d527971 keep highlighted info for 2.0.0-alpha0 2021-08-10 19:54:13 +02:00
Ceki Gulcu 153a6cabda minimal version is 8 2021-08-10 19:54:13 +02:00
Ceki Gulcu 494bd9aee9 minor doc changes 2021-08-10 19:54:13 +02:00
Ceki Gulcu 1600611850 fix SLF4J-514 2021-08-10 19:54:13 +02:00
Ceki Gulcu b56a878bc2 fix SLF4J-514 2021-08-10 19:54:13 +02:00
Ceki Gulcu 865c88e340 slightly higher tolerance 2021-08-10 19:54:13 +02:00
Ceki Gulcu 91eb61c3c9 news blurb about SLF4J-497 2021-08-10 19:54:13 +02:00
Ceki Gulcu 63ac275a5f unused imports 2021-08-10 19:54:13 +02:00
Ceki Gulcu ccce832b8f fix SLF4J-485, LoggingEventBuilder addArgument() should take Supplier<?>, not Supplier<Object> 2021-08-10 19:54:13 +02:00
Ceki Gulcu b38727956d formatting changes only 2021-08-10 19:54:13 +02:00
Ceki Gulcu 0b1d536e04 formatting changes only 2021-08-10 19:54:13 +02:00
Ceki Gulcu 6359e55d52 formatting changes only 2021-08-10 19:54:12 +02:00
Ceki Gulcu 4c1b6832f6 formatting and minor cleanup 2021-08-10 19:54:12 +02:00
Ceki Gulcu a9d4187fad news update 2021-08-10 19:54:12 +02:00
Ceki Gulcu 03c37619d5 fix SLF4J-511 2021-08-10 19:54:12 +02:00
Ceki Gulcu 6a09a76bb6 rename private method 2021-08-10 19:54:12 +02:00
Antonio Tomac 4a11208ae4 Avoid potentially "expensive" rendering of message Object to String when log level is disabled SLF4J-497 2021-08-10 19:54:12 +02:00
Ceki Gulcu 65009d8e62 minor doc fix 2021-08-10 19:54:12 +02:00
Ceki Gulcu 2f1ccdddae fix SLF4J-511 for j.u.l 2021-08-10 19:54:12 +02:00
Ceki Gulcu a739d541a5 minor edit 2021-08-10 19:54:12 +02:00
Ceki Gulcu 76cc29cb47 update link to Maven central 2021-08-10 19:54:12 +02:00
Ceki Gulcu 230573ab10 news about 1.7.30 2021-08-10 19:54:12 +02:00
Ceki Gulcu b0e3ad34f4 minor refactoring, docs 2021-08-10 19:54:12 +02:00
David Harsha a0319ce725 Fix NOP fallback memory leak
Substitute loggers are not getting "fixed" when no SLF4J provider is
found, which means `SUBST_PROVIDER` will add messages to its
`LinkedBlockingQueue` until the process runs out of memory.

`NoBindingMultithreadedInitializationTest` doesn't contain any
assertions of its own because `MultithreadedInitializationTest` already
asserts loggers are fixed in `assertAllSubstLoggersAreFixed`.

https://jira.qos.ch/browse/SLF4J-469
2021-08-10 19:54:12 +02:00
Ceki Gulcu 78b1f19a64 latest stable is 1.7.29 2021-08-10 19:54:12 +02:00
Björn Kautler 2d3c03622e Make slf4j with java.util.ServiceLoader properly work in OSGi by using the Service Loader Mediator Specification 2021-08-10 19:54:12 +02:00
Ceki Gulcu 6719babbce minor edit 2021-08-10 19:54:11 +02:00
Ceki Gulcu 17528421bf fix SLF4J-475 2021-08-10 19:54:11 +02:00
Ceki Gulcu 6ec50c7b47 minor javadoc edits 2021-08-10 19:54:11 +02:00
Ceki Gulcu ce640dbce2 skip assembly 2021-08-10 19:54:11 +02:00
Ceki Gulcu fbadf47724 updated redirect.html 2021-08-10 19:54:11 +02:00
Ceki Gulcu d779d080e4 don't put on Maven Central 2021-08-10 19:54:11 +02:00
Hervé Boutemy ec75e2b0f3 this module is Apache 2.0 licensed 2021-08-10 19:54:11 +02:00
Ceki Gulcu d03c5fe016 add redirect.html to src control 2021-08-10 19:54:11 +02:00
Ceki Gulcu 9213667ba2 remove link to tar.gz or zip distributions 2021-08-10 19:54:11 +02:00
Ceki Gulcu 8ee427d6bb document release info for 2.0-alpha1 2021-08-10 19:54:11 +02:00
Ceki Gulcu ed1ffb325a start work on 2.0.0-alpha2-SNAPSHOT 2021-08-10 19:54:11 +02:00
Ceki Gulcu fdf496daf2 version 2.0.0-alpha1 2021-08-10 19:54:11 +02:00
Ceki Gulcu 7fbe973ad9 have slf4j log markers and key-value pairs by default 2021-08-10 19:54:11 +02:00
Ceki Gulcu 13736433b1 makeLoggingEventBuilder made public 2021-08-10 19:54:11 +02:00
Ceki Gulcu c81f6cfdbd cosmetic changes 2021-08-10 19:54:11 +02:00
Ceki Gulcu 7202302537 fix test 2021-08-10 19:54:10 +02:00
Ceki Gulcu 6eaeb0f6af 'fix build, other changes 2021-08-10 19:54:10 +02:00
Ceki Gulcu a9f84d58b3 API consolidation 2021-08-10 19:54:10 +02:00
Ceki Gulcu c1c8d21bc4 minor edits 2021-08-10 19:54:10 +02:00
Sebastian Schuberth 854d6fbf79 Fix the SCM connection URL in pom.xml
The "connection" should be an URL valid for read-only access and has to follow
the syntax as described at https://maven.apache.org/pom.html#SCM.
2021-08-10 19:54:10 +02:00
Wessel van Norel a35c1d331d Fix the build and a typo 2021-08-10 19:54:10 +02:00
Ceki Gulcu ea8da7fedd refactored EventRecodingLogger and EventRecodingLoggerTest 2021-08-10 19:54:10 +02:00
Ceki Gulcu 7e6e3d1f24 move methods from Util back to MessageFormatter 2021-08-10 19:54:10 +02:00
Wessel van Norel 176e067fb9 SLF4j-466: if was missing a space 2021-08-10 19:54:10 +02:00
Wessel van Norel 1238dbcb0b SLF4j-466: fixed typo in javadoc 2021-08-10 19:54:10 +02:00
Wessel van Norel 1df318d08a SLF4j-466: added missing newline at end of file 2021-08-10 19:54:10 +02:00
Wessel van Norel 315a95824b SLF4j-466: only call arraycopy if we have elements to copy 2021-08-10 19:54:10 +02:00
Wessel van Norel 21c1be85ab SLF4j-466: put the throwable at the right place of the SubstituteLoggingEvent, introduced two more recordEvent methods for the two object argument log statements 2021-08-10 19:54:10 +02:00
Wessel van Norel 7af8f7e2f4 SLF4j-466: Move two methods from MessageFormatter to Util so they can be used by the EventRecordingLogger as well 2021-08-10 19:54:09 +02:00
Wessel van Norel 50eec4afd6 SLF4j-466: add missing marker in one of the warn methods 2021-08-10 19:54:09 +02:00
Wessel van Norel 1cd31dc9bb SLF4j-466: Add test for all happy flow cases 2021-08-10 19:54:09 +02:00
Wessel van Norel 3a06ff0b19 Change the java indent from 2 to 4. 2021-08-10 19:54:09 +02:00
Ceki Gulcu f9b0656ad8 1.7.28 notes 2021-08-10 19:54:09 +02:00
Ceki Gulcu 01340b2bcf typo fix 2021-08-10 19:54:09 +02:00
Ceki Gulcu 9ce38e487b update to README.md 2021-08-10 19:54:09 +02:00
Ceki Gulcu a73b744853 misplaced test class 2021-08-10 19:54:09 +02:00
Ceki Gulcu cebdf810d6 misplaced test class 2021-08-10 19:54:09 +02:00
Ceki Gulcu 21be0bccef minor edit 2021-08-10 19:54:09 +02:00
Ceki Gulcu df48717c87 fix SLF4J-463 2021-08-10 19:54:09 +02:00
Ceki Gulcu 334ef9a266 update 1,7,27 release information 2021-08-10 19:54:09 +02:00
Ceki Gulcu a0030b6e6a allow SubstitutableLoggerTest to pass 2021-08-10 19:54:09 +02:00
Ceki Gulcu e108a279c7 bump version 2021-08-10 19:54:09 +02:00
Ceki Gulcu 5f45225565 refactor EventBuilder construction 2021-08-10 19:54:08 +02:00
Artsiom Chapialiou efeb3665c1 fix JavaDoc typo 2021-08-10 19:54:08 +02:00
Ceki Gulcu 456e8a8841 ongoing doc improvements 2021-08-10 19:54:08 +02:00
Ceki Gulcu 383f008a05 doc fixes 2021-08-10 19:54:08 +02:00
Ceki Gulcu 6f1583fb01 document fluent api 2021-08-10 19:54:08 +02:00
Ceki Gulcu 69338e78f3 documentating fluent api 2021-08-10 19:54:08 +02:00
Ceki Gulcu f0674e9648 attempt to fix slf4j-migrator Maven Central upload issue 2021-08-10 19:54:08 +02:00
Nicolai Parlog 3c4b29b061 Relax service discovery in test 2021-08-10 19:46:32 +02:00
Nicolai Parlog fa20cc51be Ensure `ResourceBundle::getString` can't crash program 2021-08-10 19:46:32 +02:00
Nicolai Parlog 258caf4a61 Polish 2021-08-10 19:46:32 +02:00
Nicolai Parlog b67dabb03d Set up testing 2021-08-10 19:46:32 +02:00
Nicolai Parlog e2f0fca4ad Add service provider-configuration file for use on class path 2021-08-10 19:46:32 +02:00
Nicolai Parlog 1d4daa1c53 Import proof of concept 2021-08-10 19:46:32 +02:00
Nicolai Parlog 8c2ee1378e Create project structure 2021-08-10 19:46:32 +02:00
Ceki Gulcu 877817a5a3 start work on 2.0.0-alpha4-SNAPSHOT
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
2021-08-10 16:09:37 +02:00
gnp d8b223e379
Fix typo: "apllications" --> "applications" 2020-10-13 09:29:15 -07:00
290 changed files with 4593 additions and 11128 deletions

2
.github/FUNDING.yml vendored Normal file
View File

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

47
.github/workflows/main.yml vendored Normal file
View File

@ -0,0 +1,47 @@
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

12
.github/workflows/toolchains.xml vendored Normal file
View File

@ -0,0 +1,12 @@
<?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

@ -13,4 +13,9 @@ install: /bin/true
script:
- mvn clean
- mvn install
- mvn install
cache:
directories:
- $HOME/.m2

1
FUNDING.yml Normal file
View File

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

View File

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

View File

@ -1,16 +1,40 @@
# 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, 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).
# Build Status
[![Build Status](https://travis-ci.org/qos-ch/slf4j.svg)](https://travis-ci.org/qos-ch/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.
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.
All versions upto and including 1.7.x require Java 5 or later to
build. SLF4J version 2.0.x requires Java 9 or later.
SLF4J version 2.0.x will run under Java 8 but requires Java 9 or later to build.
# How to contribute pull requests
@ -21,28 +45,25 @@ 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](http://www.slf4j.org/bug-reporting.html) to initiatite the
discussion. Note that we ask pull requests to be linked to a [Jira
ticket](https://jira.qos.ch/).
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 you hopefuly created in Step 2. Be
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
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
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 from your commit page on github.
6. Submit a pull request to SLF4J from your commit page on GitHub.
7. Did we mention that you will be asked to link your pull request
with a Jira ticket?

69
SECURITY.md Normal file
View File

@ -0,0 +1,69 @@
## 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

@ -82,12 +82,12 @@
</target>
<target name="testAll" depends="init,
testNoProvider150,
testNoProvider150,
testMismatch,
testMatch,
testMultiBinding,
testFuture_16Series,
testActiveSecurityManager">
testMultiBinding,
testFuture_16Series"
>
</target>
@ -201,7 +201,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"/>

View File

@ -66,7 +66,7 @@
<!-- for some reason if mvn is invoked from the parent directory, junit gets
invoked from the parent dir, which messes up theses tests. Hence, the
invoked from the parent dir, which messes up these tests. Hence, the
fork="yes" dir="${basedir}" -->
<!--
@ -107,4 +107,4 @@
</junit>
</target>
</project>
</project>

View File

@ -7,7 +7,8 @@
<parent>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-parent</artifactId>
<version>2.0.0-alpha3</version>
<version>2.0.19-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
<artifactId>integration</artifactId>

View File

@ -27,6 +27,7 @@ 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;
@ -43,11 +44,13 @@ public class CompatibilityAssertionTest {
@Before
public void setUp() throws Exception {
System.setProperty(SLF4J_INTERNAL_VERBOSITY_KEY, "debug");
System.setErr(sps);
}
@After
public void tearDown() throws Exception {
System.clearProperty(SLF4J_INTERNAL_VERBOSITY_KEY);
System.setErr(old);
}
@ -56,9 +59,13 @@ public class CompatibilityAssertionTest {
Logger logger = LoggerFactory.getLogger(this.getClass());
String msg = "hello world " + diff;
logger.info(msg);
assertEquals(1, sps.stringList.size());
assertEquals(2, sps.stringList.size());
String s0 = (String) sps.stringList.get(0);
assertTrue(s0.contains(msg));
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));
}
}

View File

@ -55,11 +55,13 @@ public class MultiBindingAssertionTest {
String msg = "hello world " + diff;
logger.info(msg);
List<String> list = sps.stringList;
assertMsgContains(list, 0, "Class path contains multiple SLF4J providers.");
assertMsgContains(list, 1, "Found provider");
assertMsgContains(list, 2, "Found provider");
assertMsgContains(list, 3, "See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.");
assertMsgContains(list, 4, "Actual provider is of type [");
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 [");
}
void assertMsgContains(List<String> strList, int index, String msg) {

View File

@ -28,12 +28,12 @@ public class OutputVerifier {
}
{
String s = (String) sps.stringList.get(2);
assertTrue(s.contains("SLF4J: See http://www.slf4j.org/codes.html#noProviders for further details."));
assertTrue(s.contains("See https://www.slf4j.org/codes.html#noProviders for further details."));
}
{
String s = (String) sps.stringList.get(3);
assertTrue(s.contains("SLF4J: Class path contains SLF4J bindings targeting slf4j-api versions prior to 1.8."));
assertTrue(s.contains("Class path contains SLF4J bindings targeting slf4j-api versions 1.7.x or earlier."));
}
{
@ -42,7 +42,7 @@ public class OutputVerifier {
}
{
String s = (String) sps.stringList.get(5);
assertTrue(s.contains("See http://www.slf4j.org/codes.html#ignoredBindings for an explanation"));
assertTrue(s.contains("See https://www.slf4j.org/codes.html#ignoredBindings for an explanation"));
}
}

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<String>();
List<String> stringList = new ArrayList<>();
public StringPrintStream(PrintStream ps) {
super(ps);

View File

@ -7,7 +7,7 @@ import junit.framework.TestCase;
public class Issue324Test extends TestCase {
public void testLoggerCreationInPresenseOfSecurityManager() {
public void testLoggerCreationInPresenceOfSecurityManager() {
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<BundleEvent>();
List<BundleEvent> eventList = new ArrayList<>();
public void bundleChanged(BundleEvent be) {
eventList.add(be);
@ -45,16 +45,14 @@ public class CheckingBundleListener implements BundleListener {
}
public void dumpAll() {
for (int i = 0; i < eventList.size(); i++) {
BundleEvent fe = (BundleEvent) eventList.get(i);
for (BundleEvent fe : eventList) {
dump(fe);
}
}
boolean exists(String bundleName) {
for (int i = 0; i < eventList.size(); i++) {
BundleEvent fe = (BundleEvent) eventList.get(i);
Bundle b = fe.getBundle();
for (BundleEvent bundleEvent : eventList) {
Bundle b = bundleEvent.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<Object>();
List<Object> list = new ArrayList<>();
// 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,8 +32,9 @@ import org.osgi.framework.FrameworkListener;
public class FrameworkErrorListener implements FrameworkListener {
public List<FrameworkEvent> errorList = new ArrayList<FrameworkEvent>();
public List<FrameworkEvent> errorList = new ArrayList<>();
@Override
public void frameworkEvent(FrameworkEvent fe) {
if (fe.getType() == FrameworkEvent.ERROR) {
errorList.add(fe);
@ -54,9 +55,8 @@ public class FrameworkErrorListener implements FrameworkListener {
}
public void dumpAll() {
for (int i = 0; i < errorList.size(); i++) {
FrameworkEvent fe = (FrameworkEvent) errorList.get(i);
dump(fe);
for (FrameworkEvent frameworkEvent : errorList) {
dump(frameworkEvent);
}
}
}

View File

@ -5,7 +5,8 @@
<parent>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-parent</artifactId>
<version>2.0.0-alpha3</version>
<version>2.0.19-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -18,7 +19,7 @@
<licenses>
<license>
<name>Apache License, Version 2.0</name>
<name>Apache-2.0</name>
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
@ -27,7 +28,7 @@
<properties>
<module-name>org.apache.commons.logging</module-name>
</properties>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
@ -39,5 +40,19 @@
<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

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

View File

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

View File

@ -64,7 +64,7 @@ public class SLF4JLogFactory extends LogFactory {
* Public no-arguments constructor required by the lookup mechanism.
*/
public SLF4JLogFactory() {
loggerMap = new ConcurrentHashMap<String, Log>();
loggerMap = new ConcurrentHashMap<>();
}
// ----------------------------------------------------- Manifest Constants
@ -105,12 +105,12 @@ public class SLF4JLogFactory extends LogFactory {
@SuppressWarnings("unchecked")
public String[] getAttributeNames() {
List<String> names = new ArrayList<String>();
List<String> names = new ArrayList<>();
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);
}
@ -173,12 +173,10 @@ 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 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 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();
@ -216,4 +214,4 @@ public class SLF4JLogFactory extends LogFactory {
}
}
}
}

View File

@ -673,15 +673,13 @@ public class SimpleLog implements Log, Serializable {
}
private static InputStream getResourceAsStream(final String name) {
return AccessController.doPrivileged(new PrivilegedAction<InputStream>() {
public InputStream run() {
ClassLoader threadCL = getContextClassLoader();
return AccessController.doPrivileged((PrivilegedAction<InputStream>) () -> {
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 as such, all the logging systems that SLF4J supports,
covers. 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,9 +0,0 @@
Implementation-Title: jcl-over-slf4j
Bundle-ManifestVersion: 2
Bundle-SymbolicName: jcl.over.slf4j
Bundle-Name: jcl-over-slf4j
Bundle-Vendor: SLF4J.ORG
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
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

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

View File

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

View File

@ -79,12 +79,12 @@ 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>If you are concerned about application performance, then use of <code>SLF4JBridgeHandler</code>
* is appropriate only if any one the following two conditions is true:
* is appropriate only if any of the following conditions is true:
* <ol>
* <li>few j.u.l. logging statements are in play</li>
* <li>LevelChangePropagator has been installed</li>
@ -93,7 +93,7 @@ import org.slf4j.spi.LocationAwareLogger;
* <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 MAFIFEST.MF file in <em>jul-to-slf4j.jar</em> declares <b>jul_to_slf4j</b> as
* 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).
@ -143,9 +143,9 @@ public class SLF4JBridgeHandler extends Handler {
public static void uninstall() throws SecurityException {
java.util.logging.Logger rootLogger = getRootLogger();
Handler[] handlers = rootLogger.getHandlers();
for (int i = 0; i < handlers.length; i++) {
if (handlers[i] instanceof SLF4JBridgeHandler) {
rootLogger.removeHandler(handlers[i]);
for (Handler handler : handlers) {
if (handler instanceof SLF4JBridgeHandler) {
rootLogger.removeHandler(handler);
}
}
}
@ -153,14 +153,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 other wise
* @return true if SLF4JBridgeHandler is already installed, false otherwise
*
*/
public static boolean isInstalled() {
java.util.logging.Logger rootLogger = getRootLogger();
Handler[] handlers = rootLogger.getHandlers();
for (int i = 0; i < handlers.length; i++) {
if (handlers[i] instanceof SLF4JBridgeHandler) {
for (Handler handler : handlers) {
if (handler instanceof SLF4JBridgeHandler) {
return true;
}
}
@ -174,8 +174,8 @@ public class SLF4JBridgeHandler extends Handler {
public static void removeHandlersForRootLogger() {
java.util.logging.Logger rootLogger = getRootLogger();
java.util.logging.Handler[] handlers = rootLogger.getHandlers();
for (int i = 0; i < handlers.length; i++) {
rootLogger.removeHandler(handlers[i]);
for (Handler handler : handlers) {
rootLogger.removeHandler(handler);
}
}

View File

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

View File

@ -1,8 +0,0 @@
Bundle-ManifestVersion: 2
Bundle-SymbolicName: jul.to.slf4j
Bundle-Name: jul-to-slf4j
Bundle-Vendor: SLF4J.ORG
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
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}
Automatic-Module-Name: jul.to.slf4j

View File

@ -32,7 +32,7 @@ import org.apache.log4j.spi.LoggingEvent;
public class ListAppender extends AppenderSkeleton {
public List<LoggingEvent> list = new ArrayList<LoggingEvent>();
public List<LoggingEvent> list = new ArrayList<>();
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 (int i = 0; i < existingHandlers.length; i++) {
julRootLogger.removeHandler(existingHandlers[i]);
for (Handler existingHandler : existingHandlers) {
julRootLogger.removeHandler(existingHandler);
}
log4jRoot = org.apache.log4j.Logger.getRootLogger();
log4jRoot.addAppender(fileAppender);
@ -68,8 +68,8 @@ public class SLF4JBridgeHandlerPerfTest {
SLF4JBridgeHandler.uninstall();
fileAppender.close();
log4jRoot.getLoggerRepository().resetConfiguration();
for (int i = 0; i < existingHandlers.length; i++) {
julRootLogger.addHandler(existingHandlers[i]);
for (Handler existingHandler : existingHandlers) {
julRootLogger.addHandler(existingHandler);
}
}

View File

@ -42,14 +42,16 @@ public class SLF4JBridgeHandlerTest {
ListAppender listAppender = new ListAppender();
org.apache.log4j.Logger log4jRoot;
java.util.logging.Logger julLogger = java.util.logging.Logger.getLogger("yay");
java.util.logging.Logger julLogger = java.util.logging.Logger.getLogger(LOGGER_NAME);
java.util.logging.Logger julRootLogger = java.util.logging.Logger.getLogger("");
@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
@ -61,6 +63,7 @@ public class SLF4JBridgeHandlerTest {
@Test
public void testSmoke() {
SLF4JBridgeHandler.install();
String msg = "msg";
julLogger.info(msg);
assertEquals(1, listAppender.list.size());
@ -77,6 +80,19 @@ 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() {
@ -101,6 +117,8 @@ public class SLF4JBridgeHandlerTest {
assertLevel(i++, org.apache.log4j.Level.ERROR);
}
@Test
public void testLogWithResourceBundle() {
SLF4JBridgeHandler.install();
@ -115,7 +133,7 @@ public class SLF4JBridgeHandlerTest {
julResourceBundleLogger.info(msg);
assertEquals(1, listAppender.list.size());
LoggingEvent le = (LoggingEvent) listAppender.list.get(0);
LoggingEvent le = listAppender.list.get(0);
assertEquals(LOGGER_NAME, le.getLoggerName());
assertEquals(expectedMsg, le.getMessage());
}
@ -149,19 +167,19 @@ public class SLF4JBridgeHandlerTest {
LoggingEvent le = null;
le = (LoggingEvent) listAppender.list.get(0);
le = listAppender.list.get(0);
assertEquals("foo", le.getLoggerName());
assertEquals(expectedMsg1, le.getMessage());
le = (LoggingEvent) listAppender.list.get(1);
le = listAppender.list.get(1);
assertEquals("foo", le.getLoggerName());
assertEquals(expectedMsg2, le.getMessage());
le = (LoggingEvent) listAppender.list.get(2);
le = listAppender.list.get(2);
assertEquals("foo", le.getLoggerName());
assertEquals(expectedMsg3, le.getMessage());
le = (LoggingEvent) listAppender.list.get(3);
le = listAppender.list.get(3);
assertEquals("yay", le.getLoggerName());
assertEquals(expectedMsg3, le.getMessage());
}
@ -173,7 +191,7 @@ public class SLF4JBridgeHandlerTest {
julLogger.logp(Level.INFO, "SLF4JBridgeHandlerTest", "testLogWithPlaceholderNoParameters", msg, new Object[0]);
assertEquals(1, listAppender.list.size());
LoggingEvent le = (LoggingEvent) listAppender.list.get(0);
LoggingEvent le = listAppender.list.get(0);
assertEquals(LOGGER_NAME, le.getLoggerName());
assertEquals(msg, le.getMessage());
}
@ -187,7 +205,7 @@ public class SLF4JBridgeHandlerTest {
julLogger.log(Level.INFO, msg, "ignored parameter due to IllegalArgumentException");
assertEquals(1, listAppender.list.size());
LoggingEvent le = (LoggingEvent) listAppender.list.get(0);
LoggingEvent le = listAppender.list.get(0);
assertEquals(msg, le.getMessage());
}
@ -197,12 +215,12 @@ public class SLF4JBridgeHandlerTest {
String msg = null;
julLogger.log(Level.INFO, msg);
assertEquals(1, listAppender.list.size());
LoggingEvent le = (LoggingEvent) listAppender.list.get(0);
LoggingEvent le = listAppender.list.get(0);
assertEquals("", le.getMessage());
}
void assertLevel(int index, org.apache.log4j.Level expectedLevel) {
LoggingEvent le = (LoggingEvent) listAppender.list.get(index);
LoggingEvent le = listAppender.list.get(index);
assertEquals(expectedLevel, le.getLevel());
}
}

View File

@ -0,0 +1,176 @@
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

@ -1,137 +0,0 @@
<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>

View File

@ -1,17 +0,0 @@
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

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

View File

@ -1,39 +0,0 @@
/**
* 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

@ -1,46 +0,0 @@
/**
* 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

@ -1,169 +0,0 @@
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,7 +7,8 @@
<parent>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-parent</artifactId>
<version>2.0.0-alpha3</version>
<version>2.0.19-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
@ -20,8 +21,8 @@
<licenses>
<license>
<name>Apache Software Licenses</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<name>Apache-2.0</name>
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
</license>
</licenses>
@ -41,4 +42,20 @@
</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

@ -114,7 +114,7 @@ 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 an layout using the configuration information at its
* configure a 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

View File

@ -45,12 +45,12 @@ public class Category {
private static final String CATEGORY_FQCN = Category.class.getName();
private String name;
private final String name;
protected org.slf4j.Logger slf4jLogger;
private org.slf4j.spi.LocationAwareLogger locationAwareLogger;
private static Marker FATAL_MARKER = MarkerFactory.getMarker("FATAL");
private static final Marker FATAL_MARKER = MarkerFactory.getMarker("FATAL");
Category(String name) {
this.name = name;

View File

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

View File

@ -187,7 +187,7 @@ public class Priority {
*
* @param val an integer value
* @param defaultPriority a default priority value
* @return correspoding Priority value
* @return corresponding Priority value
*/
@Deprecated
public static Priority toPriority(int val, Priority defaultPriority) {
@ -204,4 +204,4 @@ public class Priority {
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;
/**
* An nop implementation of PropertyConfigurator.
* A no-op implementation of PropertyConfigurator.
*/
public class PropertyConfigurator implements Configurator {
public static void configure(Properties properties) {

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>
where as internal error messages are sent to
whereas internal error messages are sent to
<code>System.err</code>. All internal messages are prepended with
the string "log4j: ".
@ -40,7 +40,7 @@ public class LogLog {
<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";
/**
@ -49,7 +49,7 @@ public class LogLog {
<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.
*/

View File

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

View File

@ -1,13 +0,0 @@
Implementation-Title: log4j-over-slf4j
Bundle-ManifestVersion: 2
Bundle-SymbolicName: log4j.over.slf4j
Bundle-Name: log4j-over-slf4j
Bundle-Vendor: SLF4J.ORG
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
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

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

View File

@ -0,0 +1,24 @@
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,7 +7,8 @@
<parent>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-parent</artifactId>
<version>2.0.0-alpha3</version>
<version>2.0.19-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
<artifactId>osgi-over-slf4j</artifactId>
@ -37,8 +38,27 @@
<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

@ -1,8 +0,0 @@
Implementation-Title: osgi-over-slf4j
Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.slf4j.osgi-over-slf4j
Bundle-Name: OSGi LogService implemented over SLF4J
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
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}

397
parent/pom.xml Normal file
View File

@ -0,0 +1,397 @@
<?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>

538
pom.xml
View File

@ -5,92 +5,53 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-parent</artifactId>
<version>2.0.0-alpha3</version>
<artifactId>slf4j-bom</artifactId>
<version>2.0.19-SNAPSHOT</version>
<packaging>pom</packaging>
<name>SLF4J</name>
<description>Top SLF4J project pom.xml file</description>
<url>http://www.slf4j.org</url>
<organization>
<name>QOS.ch</name>
<url>http://www.qos.ch</url>
</organization>
<inceptionYear>2005</inceptionYear>
<name>SLF4J BOM</name>
<description>SLF4J project BOM</description>
<licenses>
<license>
<name>MIT License</name>
<url>http://www.opensource.org/licenses/mit-license.php</url>
<name>MIT</name>
<url>https://opensource.org/license/mit</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>
</scm>
<properties>
<latest.stable.version>1.7.32</latest.stable.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 -->
<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>
<logback.version>1.2.3</logback.version>
<junit.version>4.12</junit.version>
<maven-site-plugin.version>3.7.1</maven-site-plugin.version>
<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
<maven-surefire-plugin.version>3.0.0-M5</maven-surefire-plugin.version>
<maven-javadoc-plugin.version>3.1.0</maven-javadoc-plugin.version>
<maven-source-plugin.version>3.2.0</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>
<build-helper-maven-plugin.version>3.2.0</build-helper-maven-plugin.version>
</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-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> -->
<module>slf4j-migrator</module>
</modules>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<properties>
<central-publishing-maven-plugin.version>0.9.0</central-publishing-maven-plugin.version>
</properties>
<dependencyManagement>
<dependencies>
@ -103,333 +64,181 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
<artifactId>slf4j-simple</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>${log4j.version}</version>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-nop</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>ch.qos.cal10n</groupId>
<artifactId>cal10n-api</artifactId>
<version>${cal10n.version}</version>
<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>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-reload4j</artifactId>
<version>${project.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.10</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>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>
<execution>
<id>default-jar</id>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<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>
<Multi-Release>true</Multi-Release>
</manifestEntries>
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
</archive>
<skipIfEmpty>true</skipIfEmpty>
</configuration>
</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>
<!-- as suggested in http://jira.qos.ch/browse/SLF4J-143 -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>${build-helper-maven-plugin.version}</version>
<executions>
<execution>
<id>parse-version</id>
<goals>
<goal>parse-version</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>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
<version>${maven-jxr-plugin.version}</version>
<configuration>
<aggregate>true</aggregate>
<javadocDir>target/site/apidocs/</javadocDir>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>${maven-javadoc-plugin.version}</version>
<version>3.6.3</version>
<configuration>
<linkJavadoc>true</linkJavadoc>
<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>
<aggregate>true</aggregate>
<additionalOptions>
<additionalOption>-Xdoclint:none</additionalOption>
</additionalOptions>
<excludePackageNames>org.slf4j.migrator:org.slf4j.migrator.*</excludePackageNames>
<sourceFileExcludes>
<sourceFileExclude>**/module-info.java</sourceFileExclude>
</sourceFileExcludes>
<groups>
<group>
<title>SLF4J packages</title>
<packages>org.slf4j:org.slf4j.*</packages>
<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>Apache log4j</title>
<title>log4j-over-slf4j redirection</title>
<packages>org.apache.log4j:org.apache.log4j.*</packages>
</group>
</groups>
</configuration>
</plugin>
<plugin>
<groupId>org.sonatype.central</groupId>
<artifactId>central-publishing-maven-plugin</artifactId>
<version>${central-publishing-maven-plugin.version}</version>
<extensions>true</extensions>
<configuration>
<publishingServerId>central</publishingServerId>
<excludeArtifacts>integration</excludeArtifacts>
</configuration>
</plugin>
</plugins>
</reporting>
</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>2.10.4</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
<configuration>
<additionalparam>-Xdoclint:none</additionalparam>
<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>
<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>
@ -452,63 +261,6 @@
</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>
<pluginRepositories>
<pluginRepository>
<id>apache-snapshot-repo</id>
<name>apache-snapshot-repo</name>
<url>https://repository.apache.org/content/groups/snapshots/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
<distributionManagement>
<site>
<id>qos_ch</id>
<url>scp://yvo.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,10 +1,18 @@
# 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,7 +29,7 @@ function echoRunAndCheck () { # echo and then run the command
then
echo Failed command: $1
exit 1;
else echo Succussful run: $1
else echo Successful run: $1
fi
}
@ -31,25 +39,24 @@ echoRunAndCheck "$MVN install"
#echoRunAndCheck "$MVN site:site"
echoRunAndCheck "$MVN javadoc:aggregate"
#echoRunAndCheck "$MVN javadoc:aggregate"
echoRunAndCheck "$MVN jxr:aggregate"
#echoRunAndCheck "$MVN jxr:aggregate"
echoRunAndCheck "$MVN assembly:single"
if [ ! -z "$PASS" ]
then
echoRunAndCheck "$MVN deploy -P javadocjar,sign-artifacts -Dgpg.passphrase=$PASS"
# WARNING deploying without cleaning may leave stale MANIFEST files
export GPG_TTY=$(tty)
echoRunAndCheck "$MVN deploy -P javadocjar,sign-artifacts"
fi
#$MVN site:deploy -N # with Java 8!!!
#checkExit "mvn site:deploy -N"
#git tag -m "tagging" -a v_${VERSION_NUMBER}
#git push --tags
git tag -m "tagging" -a v_${VERSION_NUMBER}
git push --tags
#Update release version and add next version on jira
#release version and add next version on jira
# for 1.7.x series, scp slf4j-1.7.*.tar.gz yvo.qos.ch:/var/www/www.slf4j.org/htdocs/dist/
echo Full Success

View File

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

View File

@ -7,7 +7,8 @@
<parent>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-parent</artifactId>
<version>2.0.0-alpha3</version>
<version>2.0.19-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
<artifactId>slf4j-api</artifactId>
@ -21,7 +22,7 @@
<properties>
<module-name>org.slf4j</module-name>
</properties>
<build>
<plugins>
<plugin>
@ -41,6 +42,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>${maven-jar-plugin.version}</version>
<executions>
<execution>
<id>bundle-test-jar</id>
@ -51,6 +53,27 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<configuration>
<instructions>
<Import-Package>org.slf4j.spi;version="${range;[===,+);${version_cleanup;${project.version}}}"</Import-Package>
<!-- Export the client/user package of slf4j-api version 1 to make the slf4j-api bundle in version 2 usable for bundles that only import slf4j-1.x -->
<_exportcontents><![CDATA[
*,\
org.slf4j;version="${latest.1.version}",\
org.slf4j.helpers;version="${latest.1.version}"
]]></_exportcontents>
<Require-Capability><![CDATA[
osgi.extender;filter:="(&(osgi.extender=osgi.serviceloader.processor)(version>=1.0.0)(!(version>=2.0.0)))",
osgi.serviceloader;filter:="(osgi.serviceloader=org.slf4j.spi.SLF4JServiceProvider)";osgi.serviceloader="org.slf4j.spi.SLF4JServiceProvider"
]]></Require-Capability>
</instructions>
</configuration>
</plugin>
</plugins>
</build>

View File

@ -1,5 +1,5 @@
/**
* Copyright (c) 2004-2011 QOS.ch
* Copyright (c) 2004-2022 QOS.ch
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
@ -37,6 +37,7 @@ import static org.slf4j.event.Level.TRACE;
import static org.slf4j.event.Level.WARN;
import org.slf4j.event.Level;
import org.slf4j.helpers.CheckReturnValue;
import org.slf4j.spi.DefaultLoggingEventBuilder;
import org.slf4j.spi.LoggingEventBuilder;
import org.slf4j.spi.NOPLoggingEventBuilder;
@ -46,7 +47,7 @@ import org.slf4j.spi.NOPLoggingEventBuilder;
* It is expected that logging takes place through concrete implementations
* of this interface.
*
* <h3>Typical usage pattern:</h3>
* <H3>Typical usage pattern:</H3>
* <pre>
* import org.slf4j.Logger;
* import org.slf4j.LoggerFactory;
@ -61,7 +62,7 @@ import org.slf4j.spi.NOPLoggingEventBuilder;
* oldT = t;
* t = temperature;
* <span style="color:green">logger.debug("Temperature set to {}. Old temperature was {}.", t, oldT);</span>
* if(temperature.intValue() &gt; 50) {
* if (temperature.intValue() &gt; 50) {
* <span style="color:green">logger.info("Temperature has risen above 50 degrees.");</span>
* }
* }
@ -83,7 +84,7 @@ import org.slf4j.spi.NOPLoggingEventBuilder;
public interface Logger {
/**
* Case insensitive String constant used to retrieve the name of the root logger.
* Case-insensitive String constant used to retrieve the name of the root logger.
*
* @since 1.3
*/
@ -96,23 +97,45 @@ public interface Logger {
public String getName();
/**
* Make a new {@link LoggingEventBuilder} instance as appropriate for this logger and the
* desired {@link Level} passed as parameter. If this Logger is disabled for the given Level, then
* <p>Make a new {@link LoggingEventBuilder} instance as appropriate for this logger implementation.
* This default implementation always returns a new instance of {@link DefaultLoggingEventBuilder}.</p>
* <p></p>
* <p>This method is intended to be used by logging systems implementing the SLF4J API and <b>not</b>
* by end users.</p>
* <p></p>
* <p>Also note that a {@link LoggingEventBuilder} instance should be built for all levels,
* independently of the level argument. In other words, this method is an <b>unconditional</b>
* constructor for the {@link LoggingEventBuilder} appropriate for this logger implementation.</p>
* <p></p>
* @param level desired level for the event builder
* @return a new {@link LoggingEventBuilder} instance as appropriate for <b>this</b> logger
* @since 2.0
*/
default public LoggingEventBuilder makeLoggingEventBuilder(Level level) {
return new DefaultLoggingEventBuilder(this, level);
}
/**
* Make a new {@link LoggingEventBuilder} instance as appropriate for this logger and the
* desired {@link Level} passed as parameter. If this Logger is disabled for the given Level, then
* a {@link NOPLoggingEventBuilder} is returned.
*
*
*
*
* @param level desired level for the event builder
* @return a new {@link LoggingEventBuilder} instance as appropriate for this logger
* @since 2.0
*/
default public LoggingEventBuilder makeLoggingEventBuilder(Level level) {
if(isEnabledForLevel(level)) {
return new DefaultLoggingEventBuilder(this, level);
@CheckReturnValue
default public LoggingEventBuilder atLevel(Level level) {
if (isEnabledForLevel(level)) {
return makeLoggingEventBuilder(level);
} else {
return NOPLoggingEventBuilder.singleton();
}
}
/**
* Returns whether this Logger is enabled for a given {@link Level}.
*
@ -225,6 +248,7 @@ public interface Logger {
* @return LoggingEventBuilder instance as appropriate for level TRACE
* @since 2.0
*/
@CheckReturnValue
default public LoggingEventBuilder atTrace() {
if (isTraceEnabled()) {
return makeLoggingEventBuilder(TRACE);
@ -421,6 +445,7 @@ public interface Logger {
* @return LoggingEventBuilder instance as appropriate for level DEBUG
* @since 2.0
*/
@CheckReturnValue
default public LoggingEventBuilder atDebug() {
if (isDebugEnabled()) {
return makeLoggingEventBuilder(DEBUG);
@ -499,7 +524,8 @@ public interface Logger {
* data is also taken into consideration.
*
* @param marker The marker data to take into consideration
* @return true if this logger is warn enabled, false otherwise
* @return true if this Logger is enabled for the INFO level,
* false otherwise.
*/
public boolean isInfoEnabled(Marker marker);
@ -560,6 +586,7 @@ public interface Logger {
* @return LoggingEventBuilder instance as appropriate for level INFO
* @since 2.0
*/
@CheckReturnValue
default public LoggingEventBuilder atInfo() {
if (isInfoEnabled()) {
return makeLoggingEventBuilder(INFO);
@ -700,6 +727,7 @@ public interface Logger {
* @return LoggingEventBuilder instance as appropriate for level WARN
* @since 2.0
*/
@CheckReturnValue
default public LoggingEventBuilder atWarn() {
if (isWarnEnabled()) {
return makeLoggingEventBuilder(WARN);
@ -841,6 +869,7 @@ public interface Logger {
* @return LoggingEventBuilder instance as appropriate for level ERROR
* @since 2.0
*/
@CheckReturnValue
default public LoggingEventBuilder atError() {
if (isErrorEnabled()) {
return makeLoggingEventBuilder(ERROR);

View File

@ -25,52 +25,56 @@
package org.slf4j;
import java.io.IOException;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.net.URL;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.ServiceConfigurationError;
import java.util.ServiceLoader;
import java.util.Set;
import java.util.concurrent.LinkedBlockingQueue;
import org.slf4j.event.SubstituteLoggingEvent;
import org.slf4j.helpers.NOP_FallbackServiceProvider;
import org.slf4j.helpers.SubstituteServiceProvider;
import org.slf4j.helpers.Reporter;
import org.slf4j.helpers.SubstituteLogger;
import org.slf4j.helpers.SubstituteServiceProvider;
import org.slf4j.helpers.Util;
import org.slf4j.spi.MDCAdapter;
import org.slf4j.spi.SLF4JServiceProvider;
/**
* The <code>LoggerFactory</code> is a utility class producing Loggers for
* various logging APIs, most notably for log4j, logback and JDK 1.4 logging.
* Other implementations such as {@link org.slf4j.nop.NOPLogger NOPLogger} and
* {@link org.slf4j.simple.SimpleLogger SimpleLogger} are also supported.
*
* <p><code>LoggerFactory</code> is essentially a wrapper around an
* {@link ILoggerFactory} instance bound with <code>LoggerFactory</code> at
* compile time.
*
* various logging APIs, e.g. logback, reload4j, log4j and JDK 1.4 logging.
* Other implementations such as {@link org.slf4j.helpers.NOPLogger NOPLogger} and
* SimpleLogger are also supported.
*
* <p><code>LoggerFactory</code> is essentially a wrapper around an
* {@link ILoggerFactory} instance provided by a {@link SLF4JServiceProvider}.
*
* <p>
* Please note that all methods in <code>LoggerFactory</code> are static.
*
*
* @author Alexander Dorokhine
* @author Robert Elliot
* @author Ceki G&uuml;lc&uuml;
*
*
*/
public final class LoggerFactory {
static final String CODES_PREFIX = "http://www.slf4j.org/codes.html";
static final String CODES_PREFIX = "https://www.slf4j.org/codes.html";
static final String NO_PROVIDERS_URL = CODES_PREFIX + "#noProviders";
static final String IGNORED_BINDINGS_URL = CODES_PREFIX + "#ignoredBindings";
static final String NO_STATICLOGGERBINDER_URL = CODES_PREFIX + "#StaticLoggerBinder";
static final String MULTIPLE_BINDINGS_URL = CODES_PREFIX + "#multiple_bindings";
static final String NULL_LF_URL = CODES_PREFIX + "#null_LF";
static final String VERSION_MISMATCH = CODES_PREFIX + "#version_mismatch";
static final String SUBSTITUTE_LOGGER_URL = CODES_PREFIX + "#substituteLogger";
static final String LOGGER_NAME_MISMATCH_URL = CODES_PREFIX + "#loggerNameMismatch";
@ -80,6 +84,16 @@ public final class LoggerFactory {
static final String UNSUCCESSFUL_INIT_MSG = "org.slf4j.LoggerFactory in failed state. Original exception was thrown EARLIER. See also "
+ UNSUCCESSFUL_INIT_URL;
static final String CONNECTED_WITH_MSG = "Connected with provider of type [";
/**
* System property for explicitly setting the provider class. If set and the provider could be instantiated,
* then the service loading mechanism will be bypassed.
*
* @since 2.0.9
*/
static final public String PROVIDER_PROPERTY_KEY = "slf4j.provider";
static final int UNINITIALIZED = 0;
static final int ONGOING_INITIALIZATION = 1;
static final int FAILED_INITIALIZATION = 2;
@ -98,21 +112,55 @@ public final class LoggerFactory {
static volatile SLF4JServiceProvider PROVIDER;
private static List<SLF4JServiceProvider> findServiceProviders() {
ServiceLoader<SLF4JServiceProvider> serviceLoader = ServiceLoader.load(SLF4JServiceProvider.class);
List<SLF4JServiceProvider> providerList = new ArrayList<SLF4JServiceProvider>();
for (SLF4JServiceProvider provider : serviceLoader) {
providerList.add(provider);
// Package access for tests
static List<SLF4JServiceProvider> findServiceProviders() {
List<SLF4JServiceProvider> providerList = new ArrayList<>();
// retain behaviour similar to that of 1.7 series and earlier. More specifically, use the class loader that
// loaded the present class to search for services
final ClassLoader classLoaderOfLoggerFactory = LoggerFactory.class.getClassLoader();
SLF4JServiceProvider explicitProvider = loadExplicitlySpecified(classLoaderOfLoggerFactory);
if(explicitProvider != null) {
providerList.add(explicitProvider);
return providerList;
}
ServiceLoader<SLF4JServiceProvider> serviceLoader = getServiceLoader(classLoaderOfLoggerFactory);
Iterator<SLF4JServiceProvider> iterator = serviceLoader.iterator();
while (iterator.hasNext()) {
safelyInstantiate(providerList, iterator);
}
return providerList;
}
private static ServiceLoader<SLF4JServiceProvider> getServiceLoader(final ClassLoader classLoaderOfLoggerFactory) {
ServiceLoader<SLF4JServiceProvider> serviceLoader;
SecurityManager securityManager = System.getSecurityManager();
if(securityManager == null) {
serviceLoader = ServiceLoader.load(SLF4JServiceProvider.class, classLoaderOfLoggerFactory);
} else {
final PrivilegedAction<ServiceLoader<SLF4JServiceProvider>> action = () -> ServiceLoader.load(SLF4JServiceProvider.class, classLoaderOfLoggerFactory);
serviceLoader = AccessController.doPrivileged(action);
}
return serviceLoader;
}
private static void safelyInstantiate(List<SLF4JServiceProvider> providerList, Iterator<SLF4JServiceProvider> iterator) {
try {
SLF4JServiceProvider provider = iterator.next();
providerList.add(provider);
} catch (ServiceConfigurationError e) {
Reporter.error("A service provider failed to instantiate:\n" + e.getMessage());
}
}
/**
* It is LoggerFactory's responsibility to track version changes and manage
* the compatibility list.
* <p>
* <p>
* It is assumed that all versions in the 1.6 are mutually compatible.
*/
static private final String[] API_COMPATIBILITY_LIST = new String[] { "2.0" };
@ -148,15 +196,16 @@ public final class LoggerFactory {
reportMultipleBindingAmbiguity(providersList);
if (providersList != null && !providersList.isEmpty()) {
PROVIDER = providersList.get(0);
earlyBindMDCAdapter();
// SLF4JServiceProvider.initialize() is intended to be called here and nowhere else.
PROVIDER.initialize();
INITIALIZATION_STATE = SUCCESSFUL_INITIALIZATION;
reportActualBinding(providersList);
} else {
INITIALIZATION_STATE = NOP_FALLBACK_INITIALIZATION;
Util.report("No SLF4J providers were found.");
Util.report("Defaulting to no-operation (NOP) logger implementation");
Util.report("See " + NO_PROVIDERS_URL + " for further details.");
Reporter.warn("No SLF4J providers were found.");
Reporter.warn("Defaulting to no-operation (NOP) logger implementation");
Reporter.warn("See " + NO_PROVIDERS_URL + " for further details.");
Set<URL> staticLoggerBinderPathSet = findPossibleStaticLoggerBinderPathSet();
reportIgnoredStaticLoggerBinders(staticLoggerBinderPathSet);
@ -168,27 +217,64 @@ public final class LoggerFactory {
}
}
/**
* The value of PROVIDER.getMDCAdapter() can be null while PROVIDER has not yet initialized.
*
* However, SLF4JServiceProvider implementations are expected to initialize their internal
* MDCAdapter field in their constructor or on field declaration.
*/
private static void earlyBindMDCAdapter() {
MDCAdapter mdcAdapter = PROVIDER.getMDCAdapter();
if(mdcAdapter != null) {
MDC.setMDCAdapter(mdcAdapter);
}
}
static SLF4JServiceProvider loadExplicitlySpecified(ClassLoader classLoader) {
String explicitlySpecified = System.getProperty(PROVIDER_PROPERTY_KEY);
if (null == explicitlySpecified || explicitlySpecified.isEmpty()) {
return null;
}
try {
String message = String.format("Attempting to load provider \"%s\" specified via \"%s\" system property", explicitlySpecified, PROVIDER_PROPERTY_KEY);
Reporter.info(message);
Class<?> clazz = classLoader.loadClass(explicitlySpecified);
Constructor<?> constructor = clazz.getConstructor();
Object provider = constructor.newInstance();
return (SLF4JServiceProvider) provider;
} catch (ClassNotFoundException | NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException e) {
String message = String.format("Failed to instantiate the specified SLF4JServiceProvider (%s)", explicitlySpecified);
Reporter.error(message, e);
return null;
} catch (ClassCastException e) {
String message = String.format("Specified SLF4JServiceProvider (%s) does not implement SLF4JServiceProvider interface", explicitlySpecified);
Reporter.error(message, e);
return null;
}
}
private static void reportIgnoredStaticLoggerBinders(Set<URL> staticLoggerBinderPathSet) {
if (staticLoggerBinderPathSet.isEmpty()) {
return;
}
Util.report("Class path contains SLF4J bindings targeting slf4j-api versions prior to 1.8.");
Reporter.warn("Class path contains SLF4J bindings targeting slf4j-api versions 1.7.x or earlier.");
for (URL path : staticLoggerBinderPathSet) {
Util.report("Ignoring binding found at [" + path + "]");
Reporter.warn("Ignoring binding found at [" + path + "]");
}
Util.report("See " + IGNORED_BINDINGS_URL + " for an explanation.");
Reporter.warn("See " + IGNORED_BINDINGS_URL + " for an explanation.");
}
// We need to use the name of the StaticLoggerBinder class, but we can't
// reference the class itself.
private static String STATIC_LOGGER_BINDER_PATH = "org/slf4j/impl/StaticLoggerBinder.class";
private static final String STATIC_LOGGER_BINDER_PATH = "org/slf4j/impl/StaticLoggerBinder.class";
static Set<URL> findPossibleStaticLoggerBinderPathSet() {
// use Set instead of list in order to deal with bug #138
// LinkedHashSet appropriate here because it preserves insertion order
// during iteration
Set<URL> staticLoggerBinderPathSet = new LinkedHashSet<URL>();
Set<URL> staticLoggerBinderPathSet = new LinkedHashSet<>();
try {
ClassLoader loggerFactoryClassLoader = LoggerFactory.class.getClassLoader();
Enumeration<URL> paths;
@ -202,7 +288,7 @@ public final class LoggerFactory {
staticLoggerBinderPathSet.add(path);
}
} catch (IOException ioe) {
Util.report("Error getting resources from path", ioe);
Reporter.error("Error getting resources from path", ioe);
}
return staticLoggerBinderPathSet;
}
@ -227,7 +313,7 @@ public final class LoggerFactory {
static void failedBinding(Throwable t) {
INITIALIZATION_STATE = FAILED_INITIALIZATION;
Util.report("Failed to instantiate SLF4J LoggerFactory", t);
Reporter.error("Failed to instantiate SLF4J LoggerFactory", t);
}
private static void replayEvents() {
@ -235,7 +321,7 @@ public final class LoggerFactory {
final int queueSize = queue.size();
int count = 0;
final int maxDrain = 128;
List<SubstituteLoggingEvent> eventList = new ArrayList<SubstituteLoggingEvent>(maxDrain);
List<SubstituteLoggingEvent> eventList = new ArrayList<>(maxDrain);
while (true) {
int numDrained = queue.drainTo(eventList, maxDrain);
if (numDrained == 0)
@ -272,24 +358,26 @@ public final class LoggerFactory {
if (substLogger.isDelegateNOP()) {
// nothing to do
} else if (substLogger.isDelegateEventAware()) {
substLogger.log(event);
if(substLogger.isEnabledForLevel(event.getLevel())) {
substLogger.log(event);
}
} else {
Util.report(loggerName);
Reporter.warn(loggerName);
}
}
private static void emitSubstitutionWarning() {
Util.report("The following set of substitute loggers may have been accessed");
Util.report("during the initialization phase. Logging calls during this");
Util.report("phase were not honored. However, subsequent logging calls to these");
Util.report("loggers will work as normally expected.");
Util.report("See also " + SUBSTITUTE_LOGGER_URL);
Reporter.warn("The following set of substitute loggers may have been accessed");
Reporter.warn("during the initialization phase. Logging calls during this");
Reporter.warn("phase were not honored. However, subsequent logging calls to these");
Reporter.warn("loggers will work as normally expected.");
Reporter.warn("See also " + SUBSTITUTE_LOGGER_URL);
}
private static void emitReplayWarning(int eventCount) {
Util.report("A number (" + eventCount + ") of logging calls during the initialization phase have been intercepted and are");
Util.report("now being replayed. These are subject to the filtering rules of the underlying logging system.");
Util.report("See also " + REPLAY_URL);
Reporter.warn("A number (" + eventCount + ") of logging calls during the initialization phase have been intercepted and are");
Reporter.warn("now being replayed. These are subject to the filtering rules of the underlying logging system.");
Reporter.warn("See also " + REPLAY_URL);
}
private final static void versionSanityCheck() {
@ -303,18 +391,13 @@ public final class LoggerFactory {
}
}
if (!match) {
Util.report("The requested version " + requested + " by your slf4j binding is not compatible with "
Reporter.warn("The requested version " + requested + " by your slf4j provider is not compatible with "
+ Arrays.asList(API_COMPATIBILITY_LIST).toString());
Util.report("See " + VERSION_MISMATCH + " for further details.");
Reporter.warn("See " + VERSION_MISMATCH + " for further details.");
}
} catch (java.lang.NoSuchFieldError nsfe) {
// given our large user base and SLF4J's commitment to backward
// compatibility, we cannot cry here. Only for implementations
// which willingly declare a REQUESTED_API_VERSION field do we
// emit compatibility warnings.
} catch (Throwable e) {
// we should never reach here
Util.report("Unexpected problem occured during version sanity check", e);
Reporter.error("Unexpected problem occurred during version sanity check", e);
}
}
@ -325,29 +408,36 @@ public final class LoggerFactory {
/**
* Prints a warning message on the console if multiple bindings were found
* on the class path. No reporting is done otherwise.
*
*
*/
private static void reportMultipleBindingAmbiguity(List<SLF4JServiceProvider> providerList) {
if (isAmbiguousProviderList(providerList)) {
Util.report("Class path contains multiple SLF4J providers.");
Reporter.warn("Class path contains multiple SLF4J providers.");
for (SLF4JServiceProvider provider : providerList) {
Util.report("Found provider [" + provider + "]");
Reporter.warn("Found provider [" + provider + "]");
}
Util.report("See " + MULTIPLE_BINDINGS_URL + " for an explanation.");
Reporter.warn("See " + MULTIPLE_BINDINGS_URL + " for an explanation.");
}
}
private static void reportActualBinding(List<SLF4JServiceProvider> providerList) {
// binderPathSet can be null under Android
if (!providerList.isEmpty() && isAmbiguousProviderList(providerList)) {
Util.report("Actual provider is of type [" + providerList.get(0) + "]");
// impossible since a provider has been found
if (providerList.isEmpty()) {
throw new IllegalStateException("No providers were found which is impossible after successful initialization.");
}
if (isAmbiguousProviderList(providerList)) {
Reporter.info("Actual provider is of type [" + providerList.get(0) + "]");
} else {
SLF4JServiceProvider provider = providerList.get(0);
Reporter.debug(CONNECTED_WITH_MSG + provider.getClass().getName() + "]");
}
}
/**
* Return a logger named according to the name parameter using the
* statically bound {@link ILoggerFactory} instance.
*
*
* @param name
* The name of the logger.
* @return logger
@ -360,20 +450,20 @@ public final class LoggerFactory {
/**
* Return a logger named corresponding to the class passed as parameter,
* using the statically bound {@link ILoggerFactory} instance.
*
*
* <p>
* In case the the <code>clazz</code> parameter differs from the name of the
* In case the <code>clazz</code> parameter differs from the name of the
* caller as computed internally by SLF4J, a logger name mismatch warning
* will be printed but only if the
* <code>slf4j.detectLoggerNameMismatch</code> system property is set to
* true. By default, this property is not set and no warnings will be
* printed even in case of a logger name mismatch.
*
*
* @param clazz
* the returned logger will be named after clazz
* @return logger
*
*
*
*
* @see <a
* href="http://www.slf4j.org/codes.html#loggerNameMismatch">Detected
* logger name mismatch</a>
@ -383,9 +473,9 @@ public final class LoggerFactory {
if (DETECT_LOGGER_NAME_MISMATCH) {
Class<?> autoComputedCallingClass = Util.getCallingClass();
if (autoComputedCallingClass != null && nonMatchingClasses(clazz, autoComputedCallingClass)) {
Util.report(String.format("Detected logger name mismatch. Given name: \"%s\"; computed name: \"%s\".", logger.getName(),
Reporter.warn(String.format("Detected logger name mismatch. Given name: \"%s\"; computed name: \"%s\".", logger.getName(),
autoComputedCallingClass.getName()));
Util.report("See " + LOGGER_NAME_MISMATCH_URL + " for an explanation");
Reporter.warn("See " + LOGGER_NAME_MISMATCH_URL + " for an explanation");
}
}
return logger;
@ -400,7 +490,7 @@ public final class LoggerFactory {
* <p>
* <p>
* ILoggerFactory instance is bound with this class at compile time.
*
*
* @return the ILoggerFactory instance in use
*/
public static ILoggerFactory getILoggerFactory() {
@ -409,7 +499,7 @@ public final class LoggerFactory {
/**
* Return the {@link SLF4JServiceProvider} in use.
* @return provider in use
* @since 1.8.0
*/

View File

@ -1,9 +1,33 @@
/**
* Copyright (c) 2004-2021 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;
/**
* All methods in this class are reserved for internal use, for testing purposes.
*
* <p>They can can be modified, renamed or removed at any time without notice.
* <p>They can be modified, renamed or removed at any time without notice.
*
* <p>You are strongly discouraged calling any of the methods of this class.
*

View File

@ -25,11 +25,10 @@
package org.slf4j;
import java.io.Closeable;
import java.util.Deque;
import java.util.Map;
import org.slf4j.helpers.BasicMDCAdapter;
import org.slf4j.helpers.NOPMDCAdapter;
import org.slf4j.helpers.Util;
import org.slf4j.helpers.*;
import org.slf4j.spi.MDCAdapter;
import org.slf4j.spi.SLF4JServiceProvider;
@ -64,8 +63,9 @@ import org.slf4j.spi.SLF4JServiceProvider;
public class MDC {
static final String NULL_MDCA_URL = "http://www.slf4j.org/codes.html#null_MDCA";
private static final String MDC_ADAPTER_CANNOT_BE_NULL_MESSAGE = "MDCAdapter cannot be null. See also " + NULL_MDCA_URL;
static final String NO_STATIC_MDC_BINDER_URL = "http://www.slf4j.org/codes.html#no_static_mdc_binder";
static MDCAdapter mdcAdapter;
static MDCAdapter MDC_ADAPTER;
/**
* An adapter to remove the key when done.
@ -85,14 +85,30 @@ public class MDC {
private MDC() {
}
static {
private static MDCAdapter getMDCAdapterGivenByProvider() {
SLF4JServiceProvider provider = LoggerFactory.getProvider();
if (provider != null) {
mdcAdapter = provider.getMDCAdapter();
if(provider != null) {
// If you wish to change the mdc adapter, setting the MDC.MDCAdapter variable might be insufficient.
// Keep in mind that the provider *might* perform additional internal mdcAdapter assignments that
// you would also need to replicate/adapt.
// obtain and attach the MDCAdapter from the provider
final MDCAdapter anAdapter = provider.getMDCAdapter();
emitTemporaryMDCAdapterWarningIfNeeded(provider);
return anAdapter;
} else {
Util.report("Failed to find provider.");
Util.report("Defaulting to no-operation MDCAdapter implementation.");
mdcAdapter = new NOPMDCAdapter();
Reporter.error("Failed to find provider.");
Reporter.error("Defaulting to no-operation MDCAdapter implementation.");
return new NOPMDCAdapter();
}
}
private static void emitTemporaryMDCAdapterWarningIfNeeded(SLF4JServiceProvider provider) {
boolean isSubstitute = provider instanceof SubstituteServiceProvider;
if(isSubstitute) {
Reporter.info("Temporary mdcAdapter given by SubstituteServiceProvider.");
Reporter.info("This mdcAdapter will be replaced after backend initialization has completed.");
}
}
@ -115,10 +131,10 @@ public class MDC {
if (key == null) {
throw new IllegalArgumentException("key parameter cannot be null");
}
if (mdcAdapter == null) {
throw new IllegalStateException("MDCAdapter cannot be null. See also " + NULL_MDCA_URL);
if (getMDCAdapter() == null) {
throw new IllegalStateException(MDC_ADAPTER_CANNOT_BE_NULL_MESSAGE);
}
mdcAdapter.put(key, val);
getMDCAdapter().put(key, val);
}
/**
@ -171,10 +187,8 @@ public class MDC {
throw new IllegalArgumentException("key parameter cannot be null");
}
if (mdcAdapter == null) {
throw new IllegalStateException("MDCAdapter cannot be null. See also " + NULL_MDCA_URL);
}
return mdcAdapter.get(key);
mdcAdapterNullCheck();
return getMDCAdapter().get(key);
}
/**
@ -192,20 +206,16 @@ public class MDC {
throw new IllegalArgumentException("key parameter cannot be null");
}
if (mdcAdapter == null) {
throw new IllegalStateException("MDCAdapter cannot be null. See also " + NULL_MDCA_URL);
}
mdcAdapter.remove(key);
mdcAdapterNullCheck();
getMDCAdapter().remove(key);
}
/**
* Clear all entries in the MDC of the underlying implementation.
*/
public static void clear() {
if (mdcAdapter == null) {
throw new IllegalStateException("MDCAdapter cannot be null. See also " + NULL_MDCA_URL);
}
mdcAdapter.clear();
mdcAdapterNullCheck();
getMDCAdapter().clear();
}
/**
@ -216,10 +226,8 @@ public class MDC {
* @since 1.5.1
*/
public static Map<String, String> getCopyOfContextMap() {
if (mdcAdapter == null) {
throw new IllegalStateException("MDCAdapter cannot be null. See also " + NULL_MDCA_URL);
}
return mdcAdapter.getCopyOfContextMap();
mdcAdapterNullCheck();
return getMDCAdapter().getCopyOfContextMap();
}
/**
@ -234,20 +242,79 @@ public class MDC {
* @since 1.5.1
*/
public static void setContextMap(Map<String, String> contextMap) {
if (mdcAdapter == null) {
throw new IllegalStateException("MDCAdapter cannot be null. See also " + NULL_MDCA_URL);
}
mdcAdapter.setContextMap(contextMap);
mdcAdapterNullCheck();
getMDCAdapter().setContextMap(contextMap);
}
/**
* Returns the MDCAdapter instance currently in use.
*
*
* Since 2.0.17, if the MDCAdapter instance is null, then this method set it to use
* the adapter returned by the SLF4JProvider. However, in the vast majority of cases
* the MDCAdapter will be set earlier (during initialization) by {@link LoggerFactory}.
*
* @return the MDcAdapter instance currently in use.
* @since 1.4.2
*/
public static MDCAdapter getMDCAdapter() {
return mdcAdapter;
if(MDC_ADAPTER == null) {
MDC_ADAPTER = getMDCAdapterGivenByProvider();
}
return MDC_ADAPTER;
}
/**
* Set MDCAdapter instance to use.
*
* @since 2.0.17
*/
static void setMDCAdapter(MDCAdapter anMDCAdapter) {
if(anMDCAdapter == null) {
throw new IllegalStateException(MDC_ADAPTER_CANNOT_BE_NULL_MESSAGE);
}
MDC_ADAPTER = anMDCAdapter;
}
/**
* Push a value into the deque(stack) referenced by 'key'.
*
* @param key identifies the appropriate stack
* @param value the value to push into the stack
* @since 2.0.0
*/
static public void pushByKey(String key, String value) {
mdcAdapterNullCheck();
getMDCAdapter().pushByKey(key, value);
}
/**
* Pop the <b>stack</b> referenced by 'key' and return the value possibly null.
*
* @param key identifies the deque(stack)
* @return the value just popped. May be null/
* @since 2.0.0
*/
static public String popByKey(String key) {
mdcAdapterNullCheck();
return getMDCAdapter().popByKey(key);
}
/**
* Returns a copy of the <b>deque(stack)</b> referenced by 'key'. May be null.
*
* @param key identifies the stack
* @return copy of stack referenced by 'key'. May be null.
*
* @since 2.0.0
*/
public Deque<String> getCopyOfDequeByKey(String key) {
mdcAdapterNullCheck();
return getMDCAdapter().getCopyOfDequeByKey(key);
}
private static void mdcAdapterNullCheck() {
if (getMDCAdapter() == null) {
throw new IllegalStateException(MDC_ADAPTER_CANNOT_BE_NULL_MESSAGE);
}
}
}

View File

@ -29,14 +29,16 @@ import java.util.Iterator;
/**
* Markers are named objects used to enrich log statements. Conforming logging
* system Implementations of SLF4J determine how information conveyed by markers
* are used, if at all. In particular, many conforming logging systems ignore
* marker data.
*
* <p>
* Markers can contain references to other markers, which in turn may contain
* references of their own.
*
* system implementations of SLF4J should determine how information conveyed by
* any markers are used, if at all. Many conforming logging systems ignore marker
* data entirely.
*
* <p>Markers can contain references to nested markers, which in turn may
* contain references of their own. Note that the fluent API (new in 2.0) allows adding
* multiple markers to a logging statement. It is often preferable to use
* multiple markers instead of nested markers.
* </p>
*
* @author Ceki G&uuml;lc&uuml;
*/
public interface Marker extends Serializable {
@ -60,7 +62,11 @@ public interface Marker extends Serializable {
/**
* Add a reference to another Marker.
*
*
* <p>Note that the fluent API allows adding multiple markers to a logging statement.
* It is often preferable to use multiple markers instead of nested markers.
* </p>
*
* @param reference
* a reference to another marker
* @throws IllegalArgumentException

View File

@ -25,6 +25,7 @@
package org.slf4j;
import org.slf4j.helpers.BasicMarkerFactory;
import org.slf4j.helpers.Reporter;
import org.slf4j.helpers.Util;
import org.slf4j.spi.SLF4JServiceProvider;
@ -53,8 +54,8 @@ public class MarkerFactory {
if (provider != null) {
MARKER_FACTORY = provider.getMarkerFactory();
} else {
Util.report("Failed to find provider");
Util.report("Defaulting to BasicMarkerFactory.");
Reporter.error("Failed to find provider");
Reporter.error("Defaulting to BasicMarkerFactory.");
MARKER_FACTORY = new BasicMarkerFactory();
}
}

View File

@ -27,6 +27,8 @@ public class DefaultLoggingEvent implements LoggingEvent {
Throwable throwable;
String threadName;
long timeStamp;
String callerBoundary;
public DefaultLoggingEvent(Level level, Logger logger) {
this.logger = logger;
@ -123,4 +125,16 @@ public class DefaultLoggingEvent implements LoggingEvent {
public long getTimeStamp() {
return timeStamp;
}
public void setTimeStamp(long timeStamp) {
this.timeStamp = timeStamp;
}
public void setCallerBoundary(String fqcn) {
this.callerBoundary = fqcn;
}
public String getCallerBoundary() {
return callerBoundary;
}
}

View File

@ -12,11 +12,11 @@ import org.slf4j.helpers.SubstituteLogger;
* underlying logging framework. It is called by {@link SubstituteLogger}.
*
*
* @author Ceki G&uumllc&uuml;
* @author Ceki G&uuml;lc&uuml;
* @author Wessel van Norel
*
*/
public class EventRecodingLogger extends LegacyAbstractLogger {
public class EventRecordingLogger extends LegacyAbstractLogger {
private static final long serialVersionUID = -176083308134819629L;
@ -27,7 +27,7 @@ public class EventRecodingLogger extends LegacyAbstractLogger {
// as an event recording logger we have no choice but to record all events
final static boolean RECORD_ALL_EVENTS = true;
public EventRecodingLogger(SubstituteLogger logger, Queue<SubstituteLoggingEvent> eventQueue) {
public EventRecordingLogger(SubstituteLogger logger, Queue<SubstituteLoggingEvent> eventQueue) {
this.logger = logger;
this.name = logger.getName();
this.eventQueue = eventQueue;

View File

@ -1,5 +1,7 @@
package org.slf4j.event;
import java.util.Objects;
public class KeyValuePair {
public final String key;
@ -14,4 +16,17 @@ public class KeyValuePair {
public String toString() {
return String.valueOf(key) + "=\"" + String.valueOf(value) +"\"";
}
@Override
public boolean equals(Object o) {
if(this == o) return true;
if(o == null || getClass() != o.getClass()) return false;
KeyValuePair that = (KeyValuePair) o;
return Objects.equals(key, that.key) && Objects.equals(value, that.value);
}
@Override
public int hashCode() {
return Objects.hash(key, value);
}
}

View File

@ -17,8 +17,8 @@ public enum Level {
ERROR(ERROR_INT, "ERROR"), WARN(WARN_INT, "WARN"), INFO(INFO_INT, "INFO"), DEBUG(DEBUG_INT, "DEBUG"), TRACE(TRACE_INT, "TRACE");
private int levelInt;
private String levelStr;
private final int levelInt;
private final String levelStr;
Level(int i, String s) {
levelInt = i;

View File

@ -23,6 +23,10 @@ public interface LoggingEvent {
Object[] getArgumentArray();
/**
* List of markers in the event, might be null.
* @return markers in the event, might be null.
*/
List<Marker> getMarkers();
List<KeyValuePair> getKeyValuePairs();
@ -32,4 +36,14 @@ public interface LoggingEvent {
long getTimeStamp();
String getThreadName();
/**
* Returns the presumed caller boundary provided by the logging library (not the user of the library).
* Null by default.
*
* @return presumed caller, null by default.
*/
default String getCallerBoundary() {
return null;
}
}

View File

@ -407,17 +407,17 @@ public abstract class AbstractLogger implements Logger, Serializable {
abstract protected String getFullyQualifiedCallerName();
/**
* Given various arguments passed as parameters perform actual logging.
* Given various arguments passed as parameters, perform actual logging.
*
* <p>This method assumes that the separation of the args array into actual
* objects and a throwable has been already operated.
*
* @param level
* @param marker
* @param msg
* @param arguments
* @param throwable
* @param level the SLF4J level for this event
* @param marker The marker to be used for this event, may be null.
* @param messagePattern The message pattern which will be parsed and formatted
* @param arguments the array of arguments to be formatted, may be null
* @param throwable The exception whose stack trace should be logged, may be null
*/
abstract protected void handleNormalizedLoggingCall(Level level, Marker marker, String msg, Object[] arguments, Throwable throwable);
abstract protected void handleNormalizedLoggingCall(Level level, Marker marker, String messagePattern, Object[] arguments, Throwable throwable);
}

View File

@ -27,7 +27,6 @@ package org.slf4j.helpers;
import org.slf4j.spi.MDCAdapter;
import java.util.*;
import java.util.Map;
/**
* Basic MDC implementation, which can be used with logging systems that lack
@ -44,13 +43,15 @@ import java.util.Map;
*/
public class BasicMDCAdapter implements MDCAdapter {
private InheritableThreadLocal<Map<String, String>> inheritableThreadLocal = new InheritableThreadLocal<Map<String, String>>() {
private final ThreadLocalMapOfStacks threadLocalMapOfDeques = new ThreadLocalMapOfStacks();
private final InheritableThreadLocal<Map<String, String>> inheritableThreadLocalMap = new InheritableThreadLocal<Map<String, String>>() {
@Override
protected Map<String, String> childValue(Map<String, String> parentValue) {
if (parentValue == null) {
return null;
}
return new HashMap<String, String>(parentValue);
return new HashMap<>(parentValue);
}
};
@ -70,10 +71,10 @@ public class BasicMDCAdapter implements MDCAdapter {
if (key == null) {
throw new IllegalArgumentException("key cannot be null");
}
Map<String, String> map = inheritableThreadLocal.get();
Map<String, String> map = inheritableThreadLocalMap.get();
if (map == null) {
map = new HashMap<String, String>();
inheritableThreadLocal.set(map);
map = new HashMap<>();
inheritableThreadLocalMap.set(map);
}
map.put(key, val);
}
@ -82,7 +83,7 @@ public class BasicMDCAdapter implements MDCAdapter {
* Get the context identified by the <code>key</code> parameter.
*/
public String get(String key) {
Map<String, String> map = inheritableThreadLocal.get();
Map<String, String> map = inheritableThreadLocalMap.get();
if ((map != null) && (key != null)) {
return map.get(key);
} else {
@ -91,10 +92,10 @@ public class BasicMDCAdapter implements MDCAdapter {
}
/**
* Remove the the context identified by the <code>key</code> parameter.
* Remove the context identified by the <code>key</code> parameter.
*/
public void remove(String key) {
Map<String, String> map = inheritableThreadLocal.get();
Map<String, String> map = inheritableThreadLocalMap.get();
if (map != null) {
map.remove(key);
}
@ -104,10 +105,10 @@ public class BasicMDCAdapter implements MDCAdapter {
* Clear all entries in the MDC.
*/
public void clear() {
Map<String, String> map = inheritableThreadLocal.get();
Map<String, String> map = inheritableThreadLocalMap.get();
if (map != null) {
map.clear();
inheritableThreadLocal.remove();
inheritableThreadLocalMap.remove();
}
}
@ -118,7 +119,7 @@ public class BasicMDCAdapter implements MDCAdapter {
* @return the keys in the MDC
*/
public Set<String> getKeys() {
Map<String, String> map = inheritableThreadLocal.get();
Map<String, String> map = inheritableThreadLocalMap.get();
if (map != null) {
return map.keySet();
} else {
@ -132,9 +133,9 @@ public class BasicMDCAdapter implements MDCAdapter {
*
*/
public Map<String, String> getCopyOfContextMap() {
Map<String, String> oldMap = inheritableThreadLocal.get();
Map<String, String> oldMap = inheritableThreadLocalMap.get();
if (oldMap != null) {
return new HashMap<String, String>(oldMap);
return new HashMap<>(oldMap);
} else {
return null;
}
@ -142,9 +143,28 @@ public class BasicMDCAdapter implements MDCAdapter {
public void setContextMap(Map<String, String> contextMap) {
Map<String, String> copy = null;
if(contextMap != null) {
copy = new HashMap<String, String>(contextMap);
if (contextMap != null) {
copy = new HashMap<>(contextMap);
}
inheritableThreadLocal.set(copy);
inheritableThreadLocalMap.set(copy);
}
@Override
public void pushByKey(String key, String value) {
threadLocalMapOfDeques.pushByKey(key, value);
}
@Override
public String popByKey(String key) {
return threadLocalMapOfDeques.popByKey(key);
}
@Override
public Deque<String> getCopyOfDequeByKey(String key) {
return threadLocalMapOfDeques.getCopyOfDequeByKey(key);
}
@Override
public void clearDequeByKey(String key) {
threadLocalMapOfDeques.clearDequeByKey(key);
}
}

View File

@ -40,7 +40,7 @@ public class BasicMarker implements Marker {
private static final long serialVersionUID = -2849567615646933777L;
private final String name;
private List<Marker> referenceList = new CopyOnWriteArrayList<Marker>();
private final List<Marker> referenceList = new CopyOnWriteArrayList<>();
BasicMarker(String name) {
if (name == null) {
@ -128,9 +128,9 @@ public class BasicMarker implements Marker {
return false;
}
private static String OPEN = "[ ";
private static String CLOSE = " ]";
private static String SEP = ", ";
private static final String OPEN = "[ ";
private static final String CLOSE = " ]";
private static final String SEP = ", ";
public boolean equals(Object obj) {
if (this == obj)

View File

@ -41,7 +41,7 @@ import org.slf4j.Marker;
*/
public class BasicMarkerFactory implements IMarkerFactory {
private final ConcurrentMap<String, Marker> markerMap = new ConcurrentHashMap<String, Marker>();
private final ConcurrentMap<String, Marker> markerMap = new ConcurrentHashMap<>();
/**
* Regular users should <em>not</em> create

View File

@ -0,0 +1,30 @@
package org.slf4j.helpers;
import org.slf4j.Marker;
import java.lang.annotation.*;
/**
* <p>Used to annotate methods in the {@link org.slf4j.spi.LoggingEventBuilder} interface
* which return an instance of LoggingEventBuilder (usually as <code>this</code>). Such
* methods should be followed by one of the terminating <code>log()</code> methods returning
* <code>void</code>.</p>
* <p></p>
* <p>IntelliJ IDEA supports a check for annotations named as <code>CheckReturnValue</code>
* regardless of the containing package. For more information on this feature in IntelliJ IDEA,
* select File &#8594; Setting &#8594; Editor &#8594; Inspections and then Java &#8594; Probable Bugs &#8594;
* Result of method call ignored. </p>
* <p></p>
*
* <p>As for Eclipse, this feature has been requested in
* <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=572496">bug 572496</a></p>
*
* @author Ceki G&uuml;lc&uuml;
* @since 2.0.0-beta1
*/
@Documented
@Target( { ElementType.METHOD })
@Retention(RetentionPolicy.RUNTIME)
public @interface CheckReturnValue {
}

View File

@ -33,9 +33,9 @@ public class FormattingTuple {
static public FormattingTuple NULL = new FormattingTuple(null);
private String message;
private Throwable throwable;
private Object[] argArray;
private final String message;
private final Throwable throwable;
private final Object[] argArray;
public FormattingTuple(String message) {
this(message, null, null);

View File

@ -81,7 +81,7 @@ import java.util.Map;
* will return the string "File name is C:\file.zip".
*
* <p>
* The formatting conventions are different than those of {@link MessageFormat}
* The formatting conventions are different from those of {@link MessageFormat}
* which ships with the Java platform. This is justified by the fact that
* SLF4J's implementation is 10 times faster than that of {@link MessageFormat}.
* This local performance difference is both measurable and significant in the
@ -216,13 +216,13 @@ final public class MessageFormatter {
// itself escaped: "abc x:\\{}"
// we have to consume one backward slash
sbuf.append(messagePattern, i, j - 1);
deeplyAppendParameter(sbuf, argArray[L], new HashMap<Object[], Object>());
deeplyAppendParameter(sbuf, argArray[L], new HashMap<>());
i = j + 2;
}
} else {
// normal case
sbuf.append(messagePattern, i, j);
deeplyAppendParameter(sbuf, argArray[L], new HashMap<Object[], Object>());
deeplyAppendParameter(sbuf, argArray[L], new HashMap<>());
i = j + 2;
}
}
@ -291,7 +291,7 @@ final public class MessageFormatter {
String oAsString = o.toString();
sbuf.append(oAsString);
} catch (Throwable t) {
Util.report("SLF4J: Failed toString() invocation on an object of type [" + o.getClass().getName() + "]", t);
Reporter.error("Failed toString() invocation on an object of type [" + o.getClass().getName() + "]", t);
sbuf.append("[FAILED toString()]");
}

View File

@ -28,7 +28,7 @@ import org.slf4j.ILoggerFactory;
import org.slf4j.Logger;
/**
* NOPLoggerFactory is an trivial implementation of {@link
* NOPLoggerFactory is a trivial implementation of {@link
* ILoggerFactory} which always returns the unique instance of
* NOPLogger.
*

View File

@ -24,6 +24,7 @@
*/
package org.slf4j.helpers;
import java.util.Deque;
import java.util.Map;
import org.slf4j.spi.MDCAdapter;
@ -60,4 +61,21 @@ public class NOPMDCAdapter implements MDCAdapter {
// NOP
}
@Override
public void pushByKey(String key, String value) {
}
@Override
public String popByKey(String key) {
return null;
}
@Override
public Deque<String> getCopyOfDequeByKey(String key) {
return null;
}
public void clearDequeByKey(String key) {
}
}

View File

@ -14,9 +14,9 @@ public class NOP_FallbackServiceProvider implements SLF4JServiceProvider {
// to avoid constant folding by the compiler, this field must *not* be final
public static String REQUESTED_API_VERSION = "2.0.99"; // !final
private ILoggerFactory loggerFactory = new NOPLoggerFactory();
private IMarkerFactory markerFactory = new BasicMarkerFactory();
private MDCAdapter mdcAdapter = new NOPMDCAdapter();
private final ILoggerFactory loggerFactory = new NOPLoggerFactory();
private final IMarkerFactory markerFactory = new BasicMarkerFactory();
private final MDCAdapter mdcAdapter = new NOPMDCAdapter();
@Override

View File

@ -3,7 +3,7 @@ package org.slf4j.helpers;
import org.slf4j.event.LoggingEvent;
/**
* Holds normalized calling call parameters.
* Holds normalized call parameters.
*
* Includes utility methods such as {@link #normalize(String, Object[], Throwable)} to help the normalization of parameters.
*

View File

@ -0,0 +1,204 @@
package org.slf4j.helpers;
import java.io.PrintStream;
/**
* An internally used class for reporting internal messages generated by SLF4J itself, typically
* during initialization.
*
* <p>
* Internal reporting is performed by calling the {@link #debug(String)}, {@link #info(String)},
* {@link #warn(String)} (String)} {@link #error(String)} (String)} and
* {@link #error(String, Throwable)} methods.
* </p>
* <p>See {@link #SLF4J_INTERNAL_VERBOSITY_KEY} and {@link #SLF4J_INTERNAL_REPORT_STREAM_KEY} for
* configuration options.</p>
* <p>
* <p>
* Note that this system is independent of the logging back-end in use.
*
* @since 2.0.10
*/
public class Reporter {
/**
* this class is used internally by Reporter
*/
private enum Level {
DEBUG(0), INFO(1), WARN(2), ERROR(3);
int levelInt;
private Level(int levelInt) {
this.levelInt = levelInt;
}
private int getLevelInt() {
return levelInt;
}
}
private enum TargetChoice {
Stderr, Stdout;
}
static final String SLF4J_DEBUG_PREFIX = "SLF4J(D): ";
static final String SLF4J_INFO_PREFIX = "SLF4J(I): ";
static final String SLF4J_WARN_PREFIX = "SLF4J(W): ";
static final String SLF4J_ERROR_PREFIX = "SLF4J(E): ";
/**
* This system property controls the target for internal reports output by SLF4J.
* Recognized values for this key are "System.out", "stdout", "sysout", "System.err",
* "stderr" and "syserr".
*
* <p>By default, output is directed to "stderr".</p>
*/
public static final String SLF4J_INTERNAL_REPORT_STREAM_KEY = "slf4j.internal.report.stream";
static private final String[] SYSOUT_KEYS = {"System.out", "stdout", "sysout"};
/**
* This system property controls the internal level of chattiness
* of SLF4J. Recognized settings are "INFO", "WARN" and "ERROR". The default value is "INFO".
*/
public static final String SLF4J_INTERNAL_VERBOSITY_KEY = "slf4j.internal.verbosity";
static private final TargetChoice TARGET_CHOICE = getTargetChoice();
static private final Level INTERNAL_VERBOSITY = initVerbosity();
static private TargetChoice getTargetChoice() {
String reportStreamStr = System.getProperty(SLF4J_INTERNAL_REPORT_STREAM_KEY);
if(reportStreamStr == null || reportStreamStr.isEmpty()) {
return TargetChoice.Stderr;
}
for(String s : SYSOUT_KEYS) {
if(s.equalsIgnoreCase(reportStreamStr))
return TargetChoice.Stdout;
}
return TargetChoice.Stderr;
}
static private Level initVerbosity() {
String verbosityStr = System.getProperty(SLF4J_INTERNAL_VERBOSITY_KEY);
if(verbosityStr == null || verbosityStr.isEmpty()) {
return Level.INFO;
}
if(verbosityStr.equalsIgnoreCase("DEBUG")) {
return Level.DEBUG;
}
if(verbosityStr.equalsIgnoreCase("ERROR")) {
return Level.ERROR;
}
if(verbosityStr.equalsIgnoreCase("WARN")) {
return Level.WARN;
}
// anything else including verbosityStr.equalsIgnoreCase("INFO")
return Level.INFO;
}
static boolean isEnabledFor(Level level) {
return (level.levelInt >= INTERNAL_VERBOSITY.levelInt);
}
static private PrintStream getTarget() {
switch(TARGET_CHOICE) {
case Stdout:
return System.out;
case Stderr:
default:
return System.err;
}
}
/**
* Report an internal message of level DEBUG. Message text is prefixed with the string "SLF4J(D)",
* with (D) standing as a shorthand for DEBUG.
*
* <p>Messages of level DEBUG are be enabled when the {@link #SLF4J_INTERNAL_VERBOSITY_KEY}
* system property is set to "DEBUG" and disabled when set to "INFO", "WARN" or "ERROR". By default,
* {@link #SLF4J_INTERNAL_VERBOSITY_KEY} is set to "INFO".</p>
*
* @param msg the message text
* @since 2.0.16
*/
public static void debug(String msg) {
if(isEnabledFor(Level.DEBUG)) {
getTarget().println(SLF4J_DEBUG_PREFIX + msg);
}
}
/**
* Report an internal message of level INFO. Message text is prefixed with the string "SLF4J(I)", with
* (I) standing as a shorthand for INFO.
*
* <p>Messages of level INFO are be enabled when the {@link #SLF4J_INTERNAL_VERBOSITY_KEY} system property is
* set to "DEBUG" or "INFO" and disabled when set to "WARN" or "ERROR". By default,
* {@link #SLF4J_INTERNAL_VERBOSITY_KEY} is set to "INFO".</p>
*
* @param msg the message text
*/
public static void info(String msg) {
if(isEnabledFor(Level.INFO)) {
getTarget().println(SLF4J_INFO_PREFIX + msg);
}
}
/**
* Report an internal message of level "WARN". Message text is prefixed with the string "SLF4J(W)", with
* (W) standing as a shorthand for WARN.
*
* <p>Messages of level WARN are be enabled when the {@link #SLF4J_INTERNAL_VERBOSITY_KEY} system property is
* set to "DEBUG", "INFO" or "WARN" and disabled when set to "ERROR". By default,
* {@link #SLF4J_INTERNAL_VERBOSITY_KEY} is set to "INFO".</p>
*
* @param msg the message text
*/
static final public void warn(String msg) {
if(isEnabledFor(Level.WARN)) {
getTarget().println(SLF4J_WARN_PREFIX + msg);
}
}
/**
* Report an internal message of level "ERROR accompanied by a {@link Throwable}.
* Message text is prefixed with the string "SLF4J(E)", with (E) standing as a shorthand for ERROR.
*
* <p>Messages of level ERROR are always enabled.
*
* @param msg the message text
* @param t a Throwable
*/
static final public void error(String msg, Throwable t) {
// error cannot be disabled
getTarget().println(SLF4J_ERROR_PREFIX + msg);
getTarget().println(SLF4J_ERROR_PREFIX + "Reported exception:");
t.printStackTrace(getTarget());
}
/**
* Report an internal message of level "ERROR". Message text is prefixed with the string "SLF4J(E)",
* with (E) standing as a shorthand for ERROR.
*
* <p>Messages of level ERROR are always enabled.
*
* @param msg the message text
*/
static final public void error(String msg) {
// error cannot be disabled
getTarget().println(SLF4J_ERROR_PREFIX + msg);
}
}

View File

@ -0,0 +1,73 @@
/*
* Copyright (c) 2004-2024 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;
/**
* Various utility methods
*
* @since 2.0.14
*/
public class Slf4jEnvUtil {
/**
* Returns the current version of slf4j, or null if data is not available.
*
* @return current version or null if missing version data
* @since 2.0.14
*/
static public String slf4jVersion() {
// String moduleVersion = slf4jVersionByModule();
// if(moduleVersion != null)
// return moduleVersion;
Package pkg = Slf4jEnvUtil.class.getPackage();
if(pkg == null) {
return null;
}
final String pkgVersion = pkg.getImplementationVersion();
return pkgVersion;
}
/**
* Returns the current version of slf4j via class.getModule()
* or null if data is not available.
*
* @return current version or null if missing version data
* @since 2.0.14
*/
// static private String slf4jVersionByModule() {
// Module module = Slf4jEnvUtil.class.getModule();
// if (module == null)
// return null;
//
// ModuleDescriptor md = module.getDescriptor();
// if (md == null)
// return null;
// Optional<String> opt = md.rawVersion();
// return opt.orElse(null);
// }
}

View File

@ -30,7 +30,7 @@ import java.util.Queue;
import org.slf4j.Logger;
import org.slf4j.Marker;
import org.slf4j.event.EventRecodingLogger;
import org.slf4j.event.EventRecordingLogger;
import org.slf4j.event.Level;
import org.slf4j.event.LoggingEvent;
import org.slf4j.event.SubstituteLoggingEvent;
@ -52,8 +52,8 @@ public class SubstituteLogger implements Logger {
private volatile Logger _delegate;
private Boolean delegateEventAware;
private Method logMethodCache;
private EventRecodingLogger eventRecodingLogger;
private Queue<SubstituteLoggingEvent> eventQueue;
private EventRecordingLogger eventRecordingLogger;
private final Queue<SubstituteLoggingEvent> eventQueue;
public final boolean createdPostInitialization;
@ -72,6 +72,11 @@ public class SubstituteLogger implements Logger {
public LoggingEventBuilder makeLoggingEventBuilder(Level level) {
return delegate().makeLoggingEventBuilder(level);
}
@Override
public LoggingEventBuilder atLevel(Level level) {
return delegate().atLevel(level);
}
@Override
public boolean isEnabledForLevel(Level level) {
@ -440,10 +445,10 @@ public class SubstituteLogger implements Logger {
}
private Logger getEventRecordingLogger() {
if (eventRecodingLogger == null) {
eventRecodingLogger = new EventRecodingLogger(this, eventQueue);
if (eventRecordingLogger == null) {
eventRecordingLogger = new EventRecordingLogger(this, eventQueue);
}
return eventRecodingLogger;
return eventRecordingLogger;
}
/**

View File

@ -44,9 +44,9 @@ public class SubstituteLoggerFactory implements ILoggerFactory {
volatile boolean postInitialization = false;
final Map<String, SubstituteLogger> loggers = new ConcurrentHashMap<String, SubstituteLogger>();
final Map<String, SubstituteLogger> loggers = new ConcurrentHashMap<>();
final LinkedBlockingQueue<SubstituteLoggingEvent> eventQueue = new LinkedBlockingQueue<SubstituteLoggingEvent>();
final LinkedBlockingQueue<SubstituteLoggingEvent> eventQueue = new LinkedBlockingQueue<>();
synchronized public Logger getLogger(String name) {
SubstituteLogger logger = loggers.get(name);
@ -58,11 +58,11 @@ public class SubstituteLoggerFactory implements ILoggerFactory {
}
public List<String> getLoggerNames() {
return new ArrayList<String>(loggers.keySet());
return new ArrayList<>(loggers.keySet());
}
public List<SubstituteLogger> getLoggers() {
return new ArrayList<SubstituteLogger>(loggers.values());
return new ArrayList<>(loggers.values());
}
public LinkedBlockingQueue<SubstituteLoggingEvent> getEventQueue() {

View File

@ -6,9 +6,19 @@ import org.slf4j.spi.MDCAdapter;
import org.slf4j.spi.SLF4JServiceProvider;
public class SubstituteServiceProvider implements SLF4JServiceProvider {
private SubstituteLoggerFactory loggerFactory = new SubstituteLoggerFactory();
private IMarkerFactory markerFactory = new BasicMarkerFactory();
private MDCAdapter mdcAdapter = new BasicMDCAdapter();
private final SubstituteLoggerFactory loggerFactory = new SubstituteLoggerFactory();
// LoggerFactory expects providers to initialize markerFactory as early as possible.
private final IMarkerFactory markerFactory;
// LoggerFactory expects providers to initialize their MDCAdapter field
// as early as possible, preferably at construction time.
private final MDCAdapter mdcAdapter;
public SubstituteServiceProvider() {
markerFactory = new BasicMarkerFactory();
mdcAdapter = new BasicMDCAdapter();
}
@Override
public ILoggerFactory getLoggerFactory() {
@ -36,6 +46,5 @@ public class SubstituteServiceProvider implements SLF4JServiceProvider {
@Override
public void initialize() {
}
}

View File

@ -0,0 +1,89 @@
package org.slf4j.helpers;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.HashMap;
import java.util.Map;
/**
* A simple implementation of ThreadLocal backed Map containing values of type
* Deque<String>.
*
* @author Ceki Guuml;c&uuml;
* @since 2.0.0
*/
public class ThreadLocalMapOfStacks {
// BEWARE: Keys or values placed in a ThreadLocal should not be of a type/class
// not included in the JDK. See also https://jira.qos.ch/browse/LOGBACK-450
final ThreadLocal<Map<String, Deque<String>>> tlMapOfStacks = new ThreadLocal<>();
public void pushByKey(String key, String value) {
if (key == null)
return;
Map<String, Deque<String>> map = tlMapOfStacks.get();
if (map == null) {
map = new HashMap<>();
tlMapOfStacks.set(map);
}
Deque<String> deque = map.get(key);
if (deque == null) {
deque = new ArrayDeque<>();
}
deque.push(value);
map.put(key, deque);
}
public String popByKey(String key) {
if (key == null)
return null;
Map<String, Deque<String>> map = tlMapOfStacks.get();
if (map == null)
return null;
Deque<String> deque = map.get(key);
if (deque == null)
return null;
return deque.pop();
}
public Deque<String> getCopyOfDequeByKey(String key) {
if (key == null)
return null;
Map<String, Deque<String>> map = tlMapOfStacks.get();
if (map == null)
return null;
Deque<String> deque = map.get(key);
if (deque == null)
return null;
return new ArrayDeque<String>(deque);
}
/**
* Clear the deque(stack) referenced by 'key'.
*
* @param key identifies the stack
*
* @since 2.0.0
*/
public void clearDequeByKey(String key) {
if (key == null)
return;
Map<String, Deque<String>> map = tlMapOfStacks.get();
if (map == null)
return;
Deque<String> deque = map.get(key);
if (deque == null)
return;
deque.clear();
}
}

View File

@ -117,12 +117,26 @@ public final class Util {
return trace[i + 2];
}
/**
* See {@link Reporter#error(String, Throwable)} class for alternative.
*
* @deprecated replaced by the {@link Reporter#error(String, Throwable)} method.
* @param msg message to print
* @param t throwable to print
*/
static final public void report(String msg, Throwable t) {
System.err.println(msg);
System.err.println("Reported exception:");
t.printStackTrace();
}
/**
* See {@link Reporter} class for alternatives.
*
* @deprecated replaced by one of {@link Reporter#info(String)},
* {@link Reporter#warn(String)} or {@link Reporter#error(String)} methods.
* @param msg message to print
*/
static final public void report(String msg) {
System.err.println("SLF4J: " + msg);
}

View File

@ -0,0 +1,25 @@
package org.slf4j.spi;
import org.slf4j.event.LoggingEvent;
/**
* Additional interface to {@link LoggingEventBuilder} and
* {@link org.slf4j.event.LoggingEvent LoggingEvent}.
*
* Implementations of {@link LoggingEventBuilder} and {@link LoggingEvent} may optionally
* implement {@link CallerBoundaryAware} in order to support caller info extraction.
*
* This interface is intended for use by logging backends or logging bridges.
*
* @author Ceki Gulcu
*
*/
public interface CallerBoundaryAware {
/**
* Add a fqcn (fully qualified class name) to this event, presumed to be the caller boundary.
*
* @param fqcn
*/
void setCallerBoundary(String fqcn);
}

View File

@ -1,5 +1,29 @@
/**
* Copyright (c) 2004-2022 QOS.ch
* All rights reserved.
* <p>
* 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:
* <p>
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
* <p>
* 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.spi;
import java.util.List;
import java.util.function.Supplier;
import org.slf4j.Logger;
@ -9,7 +33,15 @@ import org.slf4j.event.KeyValuePair;
import org.slf4j.event.Level;
import org.slf4j.event.LoggingEvent;
public class DefaultLoggingEventBuilder implements LoggingEventBuilder {
/**
* Default implementation of {@link LoggingEventBuilder}
*/
public class DefaultLoggingEventBuilder implements LoggingEventBuilder, CallerBoundaryAware {
// The caller boundary when the log() methods are invoked, is this class itself.
static String DLEB_FQCN = DefaultLoggingEventBuilder.class.getName();
protected DefaultLoggingEvent loggingEvent;
protected Logger logger;
@ -21,7 +53,7 @@ public class DefaultLoggingEventBuilder implements LoggingEventBuilder {
/**
* Add a marker to the current logging event being built.
*
* <p>
* It is possible to add multiple markers to the same logging event.
*
* @param marker the marker to add
@ -40,141 +72,16 @@ public class DefaultLoggingEventBuilder implements LoggingEventBuilder {
@Override
public LoggingEventBuilder addArgument(Object p) {
loggingEvent.addArgument(p);
this.loggingEvent.addArgument(p);
return this;
}
@Override
public LoggingEventBuilder addArgument(Supplier<?> objectSupplier) {
loggingEvent.addArgument(objectSupplier.get());
this.loggingEvent.addArgument(objectSupplier.get());
return this;
}
@Override
public void log(String message) {
loggingEvent.setMessage(message);
log(loggingEvent);
}
@Override
public void log(String message, Object arg) {
loggingEvent.setMessage(message);
loggingEvent.addArgument(arg);
log(loggingEvent);
}
@Override
public void log(String message, Object arg0, Object arg1) {
loggingEvent.setMessage(message);
loggingEvent.addArgument(arg0);
loggingEvent.addArgument(arg1);
log(loggingEvent);
}
@Override
public void log(String message, Object... args) {
loggingEvent.setMessage(message);
loggingEvent.addArguments(args);
log(loggingEvent);
}
protected void log(LoggingEvent logggingEvent) {
if (logger instanceof LoggingEventAware) {
((LoggingEventAware) logger).log(logggingEvent);
} else {
logViaPublicSLF4JLoggerAPI(logggingEvent);
}
}
private void logViaPublicSLF4JLoggerAPI(LoggingEvent logggingEvent) {
Object[] argArray = logggingEvent.getArgumentArray();
int argLen = argArray == null ? 0 : argArray.length;
Throwable t = logggingEvent.getThrowable();
int tLen = t == null ? 0 : 1;
String msg = logggingEvent.getMessage();
Object[] combinedArguments = new Object[argLen + tLen];
if (argArray != null) {
System.arraycopy(argArray, 0, combinedArguments, 0, argLen);
}
if (t != null) {
combinedArguments[argLen] = t;
}
msg = mergeMarkersAndKeyValuePairs(logggingEvent, msg);
switch (logggingEvent.getLevel()) {
case TRACE:
logger.trace(msg, combinedArguments);
break;
case DEBUG:
logger.debug(msg, combinedArguments);
break;
case INFO:
logger.info(msg, combinedArguments);
break;
case WARN:
logger.warn(msg, combinedArguments);
break;
case ERROR:
logger.error(msg, combinedArguments);
break;
}
}
/**
* Prepend markers and key-value pairs to the message.
*
* @param logggingEvent
* @param msg
* @return
*/
private String mergeMarkersAndKeyValuePairs(LoggingEvent logggingEvent, String msg) {
StringBuilder sb = null;
if (loggingEvent.getMarkers() != null) {
sb = new StringBuilder();
for (Marker marker : logggingEvent.getMarkers()) {
sb.append(marker);
sb.append(' ');
}
}
if (logggingEvent.getKeyValuePairs() != null) {
if (sb == null) {
sb = new StringBuilder();
}
for (KeyValuePair kvp : logggingEvent.getKeyValuePairs()) {
sb.append(kvp.key);
sb.append('=');
sb.append(kvp.value);
sb.append(' ');
}
}
if (sb != null) {
sb.append(msg);
return sb.toString();
} else {
return msg;
}
}
@Override
public void log(Supplier<String> messageSupplier) {
if (messageSupplier == null) {
log((String) null);
} else {
log(messageSupplier.get());
}
}
@Override
public LoggingEventBuilder addKeyValue(String key, Object value) {
loggingEvent.addKeyValue(key, value);
@ -187,4 +94,184 @@ public class DefaultLoggingEventBuilder implements LoggingEventBuilder {
return this;
}
@Override
public void setCallerBoundary(String fqcn) {
this.loggingEvent.setCallerBoundary(fqcn);
}
@Override
public void log() {
log(this.loggingEvent);
}
@Override
public LoggingEventBuilder setMessage(String message) {
this.loggingEvent.setMessage(message);
return this;
}
@Override
public LoggingEventBuilder setMessage(Supplier<String> messageSupplier) {
this.loggingEvent.setMessage(messageSupplier.get());
return this;
}
@Override
public void log(String message) {
this.loggingEvent.setMessage(message);
log(this.loggingEvent);
}
@Override
public void log(String message, Object arg) {
this.loggingEvent.setMessage(message);
this.loggingEvent.addArgument(arg);
log(this.loggingEvent);
}
@Override
public void log(String message, Object arg0, Object arg1) {
this.loggingEvent.setMessage(message);
this.loggingEvent.addArgument(arg0);
this.loggingEvent.addArgument(arg1);
log(this.loggingEvent);
}
@Override
public void log(String message, Object... args) {
this.loggingEvent.setMessage(message);
this.loggingEvent.addArguments(args);
log(this.loggingEvent);
}
@Override
public void log(Supplier<String> messageSupplier) {
if(messageSupplier == null) {
log((String) null);
} else {
log(messageSupplier.get());
}
}
protected void log(LoggingEvent aLoggingEvent) {
if(aLoggingEvent.getCallerBoundary() == null) {
setCallerBoundary(DLEB_FQCN);
}
if(logger instanceof LoggingEventAware) {
((LoggingEventAware) logger).log(aLoggingEvent);
} else if(logger instanceof LocationAwareLogger) {
logViaLocationAwareLoggerAPI((LocationAwareLogger) logger, aLoggingEvent);
} else {
logViaPublicSLF4JLoggerAPI(aLoggingEvent);
}
}
private void logViaLocationAwareLoggerAPI(LocationAwareLogger locationAwareLogger, LoggingEvent aLoggingEvent) {
List<Marker> markerList = aLoggingEvent.getMarkers();
Marker firstMarker = (markerList != null && !markerList.isEmpty()) ? markerList.get(0) : null;
String mergedMessage = mergeMarkersAndKeyValuePairsAndMessage(aLoggingEvent);
locationAwareLogger.log(firstMarker, aLoggingEvent.getCallerBoundary(), aLoggingEvent.getLevel().toInt(),
mergedMessage,
aLoggingEvent.getArgumentArray(), aLoggingEvent.getThrowable());
}
private void logViaPublicSLF4JLoggerAPI(LoggingEvent aLoggingEvent) {
Object[] argArray = aLoggingEvent.getArgumentArray();
int argLen = argArray == null ? 0 : argArray.length;
Throwable t = aLoggingEvent.getThrowable();
int tLen = t == null ? 0 : 1;
Object[] combinedArguments = new Object[argLen + tLen];
if(argArray != null) {
System.arraycopy(argArray, 0, combinedArguments, 0, argLen);
}
if(t != null) {
combinedArguments[argLen] = t;
}
String mergedMessage = mergeMarkersAndKeyValuePairsAndMessage(aLoggingEvent);
switch(aLoggingEvent.getLevel()) {
case TRACE:
logger.trace(mergedMessage, combinedArguments);
break;
case DEBUG:
logger.debug(mergedMessage, combinedArguments);
break;
case INFO:
logger.info(mergedMessage, combinedArguments);
break;
case WARN:
logger.warn(mergedMessage, combinedArguments);
break;
case ERROR:
logger.error(mergedMessage, combinedArguments);
break;
}
}
/**
* Prepend markers and key-value pairs to the message.
*
* @param aLoggingEvent
*
* @return
*/
private String mergeMarkersAndKeyValuePairsAndMessage(LoggingEvent aLoggingEvent) {
StringBuilder sb = mergeMarkers(aLoggingEvent.getMarkers(), null);
sb = mergeKeyValuePairs(aLoggingEvent.getKeyValuePairs(), sb);
final String mergedMessage = mergeMessage(aLoggingEvent.getMessage(), sb);
return mergedMessage;
}
private StringBuilder mergeMarkers(List<Marker> markerList, StringBuilder sb) {
if(markerList == null || markerList.isEmpty())
return sb;
if(sb == null)
sb = new StringBuilder();
for(Marker marker : markerList) {
sb.append(marker);
sb.append(' ');
}
return sb;
}
private StringBuilder mergeKeyValuePairs(List<KeyValuePair> keyValuePairList, StringBuilder sb) {
if(keyValuePairList == null || keyValuePairList.isEmpty())
return sb;
if(sb == null)
sb = new StringBuilder();
for(KeyValuePair kvp : keyValuePairList) {
sb.append(kvp.key);
sb.append('=');
sb.append(kvp.value);
sb.append(' ');
}
return sb;
}
private String mergeMessage(String msg, StringBuilder sb) {
if(sb != null) {
sb.append(msg);
return sb.toString();
} else {
return msg;
}
}
}

View File

@ -31,6 +31,7 @@ import org.slf4j.ILoggerFactory;
* class bind with the appropriate {@link ILoggerFactory} instance.
*
* @author Ceki G&uuml;lc&uuml;
* @deprecated
*/
public interface LoggerFactoryBinder {

View File

@ -4,7 +4,17 @@ import org.slf4j.event.LoggingEvent;
/**
* A logger capable of logging from org.slf4j.event.LoggingEvent implements this interface.
*
*
* <p>Please note that when the {@link #log(LoggingEvent)} method assumes that
* the event was filtered beforehand and no further filtering needs to occur by the method itself.
* <p>
*
* <p>Implementations of this interface <b>may</b> apply further filtering but they are not
* required to do so. In other words, {@link #log(LoggingEvent)} method is free to assume that
* the event was filtered beforehand and no further filtering needs to occur in the method itself.</p>
*
* See also https://jira.qos.ch/browse/SLF4J-575
*
* @author Ceki Gulcu
* @since 2.0.0
*/

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