├── FAQ.md ├── log4jna-win32dll ├── resources │ ├── .gitignore │ └── version.properties ├── src │ ├── .gitignore │ ├── main │ │ └── resources │ │ │ ├── dll-assembly.xml │ │ │ └── sources-assembly.xml │ ├── Win32EventLogAppender.def │ ├── EventLogCategories.mc │ ├── version.rc.template │ ├── site │ │ ├── site.xml │ │ └── markdown │ │ │ └── index.md │ ├── Win32EventLogAppender.rc │ └── build.xml ├── README.md └── pom.xml ├── log4jna-api ├── Readme.md ├── src │ ├── test │ │ ├── resources │ │ │ └── Win32EventLogAppender.dll │ │ └── java │ │ │ └── org │ │ │ └── dnlock │ │ │ └── log4jna │ │ │ └── nt │ │ │ └── test │ │ │ └── Win32EventLogAppenderTest.java │ ├── site │ │ └── site.xml │ └── main │ │ └── java │ │ └── org │ │ └── dblock │ │ └── log4jna │ │ └── nt │ │ └── Win32EventLogAppender.java └── pom.xml ├── log4jna.jpg ├── log4jna-assembly ├── src │ └── main │ │ └── resources │ │ ├── demo │ │ ├── rundemo.cmd │ │ ├── Win32EventLogAppender.dll │ │ └── log4j2.xml │ │ ├── sources-assembly.xml │ │ ├── run-demo-assembly.xml │ │ └── log4jna-assembly.xml └── pom.xml ├── src └── site │ ├── resources │ └── img │ │ ├── log4jna.jpg │ │ ├── git-tag1.png │ │ ├── registry1.png │ │ ├── registry2.png │ │ ├── dependencies.png │ │ ├── maven-eclipse1.png │ │ ├── maven-eclipse2.png │ │ ├── maven-eclipse3.png │ │ └── maven-eclipse4.png │ ├── markdown │ ├── MAVENIVYGRADLE.md │ ├── index.md │ ├── CONTRIBUTING.md │ ├── ENVIRONMENT.md │ └── USAGE.md │ └── site.xml ├── .github ├── renovate.json └── workflows │ ├── Renovate.yml │ ├── Default.yml │ ├── Site.yml │ ├── Deploy.yml │ └── Release.yml ├── log4jna-demo ├── src │ ├── test │ │ ├── resources │ │ │ ├── Win32EventLogAppender.dll │ │ │ ├── log4j2.properties.rename │ │ │ ├── log4j2.xml │ │ │ └── log4j2-application.xml │ │ └── java │ │ │ └── org │ │ │ └── dblock │ │ │ └── log4jna │ │ │ └── nt │ │ │ └── demo │ │ │ └── test │ │ │ └── NewDemoTest.java │ ├── main │ │ ├── java │ │ │ └── org │ │ │ │ └── dblock │ │ │ │ └── log4jna │ │ │ │ └── nt │ │ │ │ └── demo │ │ │ │ ├── Demo.java │ │ │ │ └── NewDemo.java │ │ └── resources │ │ │ └── log4j2.xml │ └── site │ │ └── site.xml ├── Readme.md ├── pom.xml └── LICENSE.txt ├── log4jna-doc ├── org.apache.log4jna.nt.Win32EventLogAppender.registry.png ├── pom.xml └── org.apache.log4jna.nt.Win32EventLogAppender.md ├── .gitignore ├── MavenRelease.md ├── MAVENIVYGRADLE.md ├── CHANGELOG.md ├── README.md ├── CONTRIBUTING.md ├── ENVIRONMENT.md ├── LICENSE.txt ├── USAGE.md └── pom.xml /FAQ.md: -------------------------------------------------------------------------------- 1 | # Frequently Asked Questions 2 | 3 | TODO 4 | -------------------------------------------------------------------------------- /log4jna-win32dll/resources/.gitignore: -------------------------------------------------------------------------------- 1 | /date.properties 2 | -------------------------------------------------------------------------------- /log4jna-api/Readme.md: -------------------------------------------------------------------------------- 1 | Work in progress maven migration. 2 | 3 | -------------------------------------------------------------------------------- /log4jna.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dblock/log4jna/HEAD/log4jna.jpg -------------------------------------------------------------------------------- /log4jna-assembly/src/main/resources/demo/rundemo.cmd: -------------------------------------------------------------------------------- 1 | java -cp .;"./*";"./lib/*" org.dblock.log4jna.nt.demo.NewDemo -------------------------------------------------------------------------------- /src/site/resources/img/log4jna.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dblock/log4jna/HEAD/src/site/resources/img/log4jna.jpg -------------------------------------------------------------------------------- /src/site/resources/img/git-tag1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dblock/log4jna/HEAD/src/site/resources/img/git-tag1.png -------------------------------------------------------------------------------- /src/site/resources/img/registry1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dblock/log4jna/HEAD/src/site/resources/img/registry1.png -------------------------------------------------------------------------------- /src/site/resources/img/registry2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dblock/log4jna/HEAD/src/site/resources/img/registry2.png -------------------------------------------------------------------------------- /src/site/resources/img/dependencies.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dblock/log4jna/HEAD/src/site/resources/img/dependencies.png -------------------------------------------------------------------------------- /.github/renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://docs.renovatebot.com/renovate-schema.json", 3 | "packageRules": [] 4 | } -------------------------------------------------------------------------------- /src/site/resources/img/maven-eclipse1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dblock/log4jna/HEAD/src/site/resources/img/maven-eclipse1.png -------------------------------------------------------------------------------- /src/site/resources/img/maven-eclipse2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dblock/log4jna/HEAD/src/site/resources/img/maven-eclipse2.png -------------------------------------------------------------------------------- /src/site/resources/img/maven-eclipse3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dblock/log4jna/HEAD/src/site/resources/img/maven-eclipse3.png -------------------------------------------------------------------------------- /src/site/resources/img/maven-eclipse4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dblock/log4jna/HEAD/src/site/resources/img/maven-eclipse4.png -------------------------------------------------------------------------------- /log4jna-api/src/test/resources/Win32EventLogAppender.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dblock/log4jna/HEAD/log4jna-api/src/test/resources/Win32EventLogAppender.dll -------------------------------------------------------------------------------- /log4jna-demo/src/test/resources/Win32EventLogAppender.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dblock/log4jna/HEAD/log4jna-demo/src/test/resources/Win32EventLogAppender.dll -------------------------------------------------------------------------------- /log4jna-assembly/src/main/resources/demo/Win32EventLogAppender.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dblock/log4jna/HEAD/log4jna-assembly/src/main/resources/demo/Win32EventLogAppender.dll -------------------------------------------------------------------------------- /log4jna-doc/org.apache.log4jna.nt.Win32EventLogAppender.registry.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dblock/log4jna/HEAD/log4jna-doc/org.apache.log4jna.nt.Win32EventLogAppender.registry.png -------------------------------------------------------------------------------- /log4jna-win32dll/src/.gitignore: -------------------------------------------------------------------------------- 1 | /Win32EventLogAppender.h 2 | /Win32EventLogAppender.res 3 | /EventLogCategories.h 4 | /EventLogCategories.rc 5 | /MSG00001.bin 6 | /version.rc 7 | /date.properties 8 | /RC* 9 | 10 | -------------------------------------------------------------------------------- /log4jna-win32dll/resources/version.properties: -------------------------------------------------------------------------------- 1 | version.major=2 2 | version.minor=0 3 | version.build=${build.ts} 4 | version.revision=0 5 | version.major.minor=${version.major}.${version.minor} 6 | version=${version.major}.${version.minor}.${version.build}.${version.revision} 7 | copyright=(c) ${build.year} The Log4JNA Team 8 | company=The Log4JNA Team 9 | 10 | -------------------------------------------------------------------------------- /log4jna-demo/Readme.md: -------------------------------------------------------------------------------- 1 | Demo. 2 | 3 | Work in progress. 4 | 5 | To run the demo:. 6 | 7 | 1 checkout log4jna project and run "maven install" on it. 8 | 9 | 2 create the registry entries HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\Win32LogApplication\WinLogger 10 | 11 | Name: CategoryCount 12 | Type: REG_DWORD 13 | Data: 0x6 14 | 15 | Name: TypesSupported 16 | Type: REG_DWORD 17 | Data: 0x7 -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | build/date.properties 2 | log4jna/src/win32dll/EventLogCategories.h 3 | log4jna/src/win32dll/EventLogCategories.rc 4 | log4jna/src/win32dll/MSG00001.bin 5 | log4jna/src/win32dll/Win32EventLogAppender.res 6 | log4jna/src/win32dll/target/ 7 | log4jna/src/win32dll/version.rc 8 | demo/bin 9 | demo/build 10 | demo/lib 11 | log4jna/bin 12 | log4jna/build 13 | log4jna/doc 14 | log4jna/lib-test 15 | log4jna/lib 16 | log4jna/test 17 | target 18 | .settings 19 | .project 20 | .classpath 21 | /.myumldata 22 | release.properties 23 | pom.xml.releaseBackup 24 | maven.log 25 | 26 | -------------------------------------------------------------------------------- /log4jna-demo/src/main/java/org/dblock/log4jna/nt/demo/Demo.java: -------------------------------------------------------------------------------- 1 | package org.dblock.log4jna.nt.demo; 2 | 3 | import org.apache.logging.log4j.LogManager; 4 | import org.apache.logging.log4j.Logger; 5 | 6 | public class Demo { 7 | public static void main(String[] args) { 8 | try { 9 | Logger logger = LogManager.getLogger(); 10 | String message = ""; 11 | for(String arg : args) { 12 | message += arg; 13 | message += " "; 14 | } 15 | logger.debug("debug: " + message); 16 | logger.info("info: " + message); 17 | } catch (Throwable t) { 18 | t.printStackTrace(); 19 | System.exit(1); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /MavenRelease.md: -------------------------------------------------------------------------------- 1 | # Release To Maven Central 2 | 3 | To make a Log4JNA release: 4 | 5 | 1. Run the on-demand [Release GitHub Workflow](https://github.com/dblock/log4jna/actions/workflows/Release.yml). 6 | 2. Release the staging repository from [Sonatype](https://oss.sonatype.org/index.html#stagingRepositories). 7 | 3. Check whether the release made it in [Sonatype](https://oss.sonatype.org/#nexus-search;quick~log4jna). 8 | 4. Update [CHANGELOG.md](CHANGELOG.md) and any `x.y.z` references with the newly released version number, commit and push your changes. 9 | 5. Run the on-demand [Site GitHub Workflow](https://github.com/dblock/log4jna/actions/workflows/Site.yml). 10 | -------------------------------------------------------------------------------- /log4jna-win32dll/src/main/resources/dll-assembly.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | src 5 | 6 | zip 7 | 8 | false 9 | 10 | 11 | 12 | target 13 | 14 | Win32EventLogAppender.dll 15 | 16 | \ 17 | 18 | 19 | -------------------------------------------------------------------------------- /.github/workflows/Renovate.yml: -------------------------------------------------------------------------------- 1 | name: Log4JNA Dependency Update 2 | 3 | on: 4 | schedule: 5 | # The "*" (#42, asterisk) character has special semantics in YAML, so this 6 | # string has to be quoted. 7 | - cron: '0 0 * * *' 8 | 9 | workflow_dispatch: 10 | 11 | jobs: 12 | build: 13 | runs-on: ubuntu-latest 14 | 15 | name: renovate 16 | steps: 17 | # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it 18 | - uses: actions/checkout@v3 19 | 20 | # GitHub Action to run self-hosted Renovate 21 | - name: Renovate Bot GitHub Action 22 | uses: renovatebot/github-action@v36.0.0 23 | with: 24 | configurationFile: .github/renovate.json 25 | token: ${{ secrets.RENOVATE_TOKEN }} 26 | env: 27 | RENOVATE_REPOSITORIES: dblock/log4jna 28 | -------------------------------------------------------------------------------- /MAVENIVYGRADLE.md: -------------------------------------------------------------------------------- 1 | # Maven, Ivy, and Gradle Artifacts 2 | 3 | Configure your build system to get dependencies from Maven Central. 4 | 5 | ### Apache Maven 6 | 7 | Add the following to your `pom.xml` file. 8 | 9 | ```xml 10 | 11 | 12 | org.dblock.log4jna 13 | log4jna-api 14 | 2.1.0 15 | 16 | 17 | ``` 18 | 19 | ### Apache Ivy 20 | 21 | Add the following to your `ivy.xml` file. 22 | 23 | ```xml 24 | 25 | 26 | 27 | ``` 28 | 29 | ### Gradle 30 | 31 | Add the following to your `build.gradle` file 32 | 33 | ```gradle 34 | dependencies { 35 | compile group: 'org.dblock.log4jna', name: 'log4jna-api', version: '2.1.0' 36 | } 37 | ``` -------------------------------------------------------------------------------- /src/site/markdown/MAVENIVYGRADLE.md: -------------------------------------------------------------------------------- 1 | # Maven, Ivy, and Gradle Artifacts 2 | 3 | Configure your build system to get dependencies from Maven Central. 4 | 5 | ### Apache Maven 6 | 7 | Add the following to your `pom.xml` file. 8 | 9 | ```xml 10 | 11 | 12 | org.dblock.log4jna 13 | log4jna-api 14 | 2.1.0 15 | 16 | 17 | ``` 18 | 19 | ### Apache Ivy 20 | 21 | Add the following to your `ivy.xml` file. 22 | 23 | ```xml 24 | 25 | 26 | 27 | ``` 28 | 29 | ### Gradle 30 | 31 | Add the following to your `build.gradle` file 32 | 33 | ```gradle 34 | dependencies { 35 | compile group: 'org.dblock.log4jna', name: 'log4jna-api', version: '2.1.0' 36 | } 37 | ``` -------------------------------------------------------------------------------- /log4jna-win32dll/src/Win32EventLogAppender.def: -------------------------------------------------------------------------------- 1 | ; 2 | ; Licensed to the Apache Software Foundation (ASF) under one or more 3 | ; contributor license agreements. See the NOTICE file distributed with 4 | ; this work for additional information regarding copyright ownership. 5 | ; The ASF licenses this file to You under the Apache License, Version 2.0 6 | ; (the "License"); you may not use this file except in compliance with 7 | ; the License. You may obtain a copy of the License at 8 | ; 9 | ; http://www.apache.org/licenses/LICENSE-2.0 10 | ; 11 | ; Unless required by applicable law or agreed to in writing, software 12 | ; distributed under the License is distributed on an "AS IS" BASIS, 13 | ; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | ; See the License for the specific language governing permissions and 15 | ; limitations under the License. 16 | ; 17 | 18 | LIBRARY "Win32EventLogAppender" 19 | -------------------------------------------------------------------------------- /log4jna-win32dll/src/main/resources/sources-assembly.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | src 5 | 6 | zip 7 | 8 | false 9 | 10 | 11 | 12 | src 13 | 14 | build.xml 15 | EventLogCategories.mc 16 | version.rc.template 17 | Win32EventLogAppender.def 18 | Win32EventLogAppender.rc 19 | 20 | \ 21 | 22 | 23 | resources 24 | \resources 25 | 26 | 27 | -------------------------------------------------------------------------------- /log4jna-demo/src/test/resources/log4j2.properties.rename: -------------------------------------------------------------------------------- 1 | status=trace 2 | 3 | appender.console.type = Console 4 | appender.console.name = STDOUT 5 | appender.console.layout.type = PatternLayout 6 | appender.console.layout.pattern = %d{yyyy-MM-dd HH:mm:ss} %c{1} [%p] %m%n 7 | 8 | appender.winlogger.type = Win32EventLog 9 | appender.winlogger.name = Win32EventLog 10 | appender.winlogger.source=WinLogger 11 | appender.winlogger.application=Win32LogApplication 12 | appender.winlogger.eventMessageFile=src\\main\\resources\\Win32EventLogAppender.dll 13 | appender.winlogger.categoryMessageFile=src\\main\\resources\\Win32EventLogAppender.dll 14 | appender.winlogger.layout.type = PatternLayout 15 | appender.winlogger.layout.pattern = %d{yyyy-MM-dd HH:mm:ss} %c{1} [%p] %m%n 16 | 17 | 18 | logger.winlogger.name = org.dblock 19 | logger.winlogger.level = debug 20 | logger.winlogger.appenderRef.winlogger.ref = Win32EventLog 21 | 22 | 23 | logger.rolling.name = org.dblock 24 | logger.rolling.level = debug 25 | logger.rolling.additivity = false 26 | logger.rolling.appenderRef.rolling.ref = RollingFile 27 | 28 | rootLogger.level = debug 29 | rootLogger.appenderRef.stdout.ref = STDOUT -------------------------------------------------------------------------------- /log4jna-doc/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | log4jna-doc 5 | pom 6 | Log4JNA Doc 7 | FAQ and configuration documents 8 | 9 | org.dblock.log4jna 10 | log4jna 11 | 2.1.0 12 | ../ 13 | 14 | 15 | 16 | 17 | org.apache.maven.plugins 18 | maven-deploy-plugin 19 | 20 | true 21 | 22 | 23 | 24 | org.apache.maven.plugins 25 | maven-install-plugin 26 | 27 | true 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /.github/workflows/Default.yml: -------------------------------------------------------------------------------- 1 | name: Log4JNA Default Build 2 | 3 | on: 4 | push: 5 | branches: 6 | - '*' 7 | pull_request: 8 | branches: 9 | - '*' 10 | 11 | workflow_dispatch: 12 | 13 | jobs: 14 | build: 15 | strategy: 16 | matrix: 17 | entry: 18 | - { java: "8", distribution: "temurin" } 19 | - { java: "11", distribution: "temurin" } 20 | - { java: "11", distribution: "microsoft" } 21 | - { java: "17", distribution: "temurin" } 22 | - { java: "17", distribution: "microsoft" } 23 | 24 | runs-on: "windows-2019" 25 | 26 | name: Java ${{ matrix.entry.java }} ( ${{ matrix.entry.distribution }} ) 27 | steps: 28 | # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it 29 | - uses: actions/checkout@v3 30 | 31 | # Configuring Developer Command Prompt for Microsoft Visual C++ 32 | - uses: ilammy/msvc-dev-cmd@v1 33 | 34 | # Setup JDK 35 | - uses: actions/setup-java@v3 36 | with: 37 | distribution: ${{ matrix.entry.distribution }} 38 | java-version: ${{ matrix.entry.java }} 39 | 40 | # Default Build 41 | - run: mvn clean install -B 42 | -------------------------------------------------------------------------------- /log4jna-win32dll/src/EventLogCategories.mc: -------------------------------------------------------------------------------- 1 | ; 2 | ; Licensed to the Apache Software Foundation (ASF) under one 3 | ; or more contributor license agreements. See the NOTICE file 4 | ; distributed with this work for additional information 5 | ; regarding copyright ownership. The ASF licenses this file 6 | ; to you under the Apache License, Version 2.0 (the 7 | ; "License"); you may not use this file except in compliance 8 | ; with the License. You may obtain a copy of the License at 9 | ; 10 | ; http://www.apache.org/licenses/LICENSE-2.0 11 | ; 12 | ; Unless required by applicable law or agreed to in writing, 13 | ; software distributed under the License is distributed on an 14 | ; "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | ; KIND, either express or implied. See the License for the 16 | ; specific language governing permissions and limitations 17 | ; under the License. 18 | ; 19 | MessageId=1 20 | Language=English 21 | Trace 22 | . 23 | MessageId=2 24 | Language=English 25 | Debug 26 | . 27 | MessageId=3 28 | Language=English 29 | Info 30 | . 31 | MessageId=4 32 | Language=English 33 | Warn 34 | . 35 | MessageId=5 36 | Language=English 37 | Error 38 | . 39 | MessageId=6 40 | Language=English 41 | Fatal 42 | . 43 | MessageId=0x1000 44 | Language=English 45 | %1 46 | . 47 | -------------------------------------------------------------------------------- /log4jna-win32dll/src/version.rc.template: -------------------------------------------------------------------------------- 1 | VS_VERSION_INFO VERSIONINFO 2 | FILEVERSION ${version.major}, ${version.minor}, ${version.build}, ${version.revision} 3 | PRODUCTVERSION ${version.major}, ${version.minor}, ${version.build}, ${version.revision} 4 | FILEFLAGSMASK 0x17L 5 | #ifdef _DEBUG 6 | FILEFLAGS 0x1L 7 | #else 8 | FILEFLAGS 0x0L 9 | #endif 10 | FILEOS 0x4L 11 | FILETYPE 0x2L 12 | FILESUBTYPE 0x0L 13 | BEGIN 14 | BLOCK "StringFileInfo" 15 | BEGIN 16 | BLOCK "040904b0" 17 | BEGIN 18 | VALUE "CompanyName", "${company}" 19 | VALUE "FileDescription", "Message file for Win32EventLogAppender" 20 | VALUE "FileVersion", "${version.major}, ${version.minor}, ${version.build}, ${version.revision}" 21 | VALUE "InternalName", "Win32EventLogAppender" 22 | VALUE "LegalCopyright", "${copyright}" 23 | VALUE "OriginalFilename", "Win32EventLogAppender.dll" 24 | VALUE "ProductName", "Log4jna" 25 | VALUE "ProductVersion", "${version.major}, ${version.minor}, ${version.build}, ${version.revision}" 26 | VALUE "OLESelfRegister", "\0" 27 | END 28 | END 29 | BLOCK "VarFileInfo" 30 | BEGIN 31 | VALUE "Translation", 0x409, 1200 32 | END 33 | END 34 | -------------------------------------------------------------------------------- /.github/workflows/Site.yml: -------------------------------------------------------------------------------- 1 | name: Log4JNA Site Publish 2 | 3 | on: 4 | workflow_dispatch: 5 | 6 | jobs: 7 | build: 8 | strategy: 9 | matrix: 10 | entry: 11 | - { java: "8", distribution: "temurin" } 12 | 13 | runs-on: "windows-2019" 14 | 15 | name: Java ${{ matrix.entry.java }} ( ${{ matrix.entry.distribution }} ) 16 | steps: 17 | # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it 18 | - uses: actions/checkout@v3 19 | 20 | # Configuring Developer Command Prompt for Microsoft Visual C++ 21 | - uses: ilammy/msvc-dev-cmd@v1 22 | 23 | # Setup JDK 24 | - uses: actions/setup-java@v3 25 | with: 26 | distribution: ${{ matrix.entry.distribution }} 27 | java-version: ${{ matrix.entry.java }} 28 | 29 | # Set git config 30 | - run: | 31 | git config --global user.name github-actions[bot] 32 | git config --global user.email 41898282+github-actions[bot]@users.noreply.github.com 33 | 34 | # Site Publish 35 | - run: mvn clean site site:stage scm-publish:publish-scm -P site 36 | env: 37 | GITHUB_USERNAME: ${{ secrets.GIT_USERNAME }} 38 | GITHUB_TOKEN: ${{ secrets.GIT_ACCESS_TOKEN }} 39 | -------------------------------------------------------------------------------- /log4jna-assembly/src/main/resources/sources-assembly.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | src 5 | 6 | zip 7 | 8 | log4jna 9 | true 10 | 11 | 12 | 13 | .. 14 | 15 | **\src\**\*.* 16 | **\pom.xml 17 | **\log4jna-build\Maven\*.enc 18 | **\log4jna-win32dll\resources\*.* 19 | LICENSE.txt 20 | **\*.md 21 | 22 | 23 | 24 | **\target\**\*.* 25 | **\.project 26 | **\.settings 27 | **\.classpath 28 | 29 | \ 30 | 31 | 32 | -------------------------------------------------------------------------------- /log4jna-assembly/src/main/resources/run-demo-assembly.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | run-demo 5 | 6 | zip 7 | 8 | log4jna 9 | false 10 | 11 | 12 | src\main\resources\demo 13 | 14 | *.* 15 | 16 | / 17 | 18 | 19 | ..\log4jna-demo\target 20 | 21 | log4jna-demo-${project.version}.jar 22 | 23 | \ 24 | 25 | 26 | 27 | 28 | \lib 29 | true 30 | 31 | *:jar:* 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /.github/workflows/Deploy.yml: -------------------------------------------------------------------------------- 1 | name: Log4JNA Deploy 2 | 3 | on: 4 | push: 5 | branches: [master] 6 | 7 | workflow_dispatch: 8 | 9 | jobs: 10 | build: 11 | strategy: 12 | matrix: 13 | entry: 14 | - { java: "11", distribution: "temurin" } 15 | 16 | runs-on: "windows-2019" 17 | 18 | name: Java ${{ matrix.entry.java }} ( ${{ matrix.entry.distribution }} ) 19 | steps: 20 | # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it 21 | - uses: actions/checkout@v3 22 | 23 | # Configuring Developer Command Prompt for Microsoft Visual C++ 24 | - uses: ilammy/msvc-dev-cmd@v1 25 | 26 | # Setup JDK 27 | - uses: actions/setup-java@v3 28 | with: 29 | distribution: ${{ matrix.entry.distribution }} 30 | java-version: ${{ matrix.entry.java }} 31 | server-id: central 32 | server-username: MAVEN_CENTRAL_USERNAME 33 | server-password: MAVEN_CENTRAL_PASSWORD 34 | gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} 35 | gpg-passphrase: MAVEN_GPG_PASSPHRASE 36 | 37 | # Deploy 38 | - run: mvn clean site site:stage deploy -B -P deploy 39 | env: 40 | MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }} 41 | MAVEN_CENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }} 42 | MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }} 43 | -------------------------------------------------------------------------------- /log4jna-win32dll/src/site/site.xml: -------------------------------------------------------------------------------- 1 | 2 | 15 | 18 | 19 | 20 | org.apache.maven.skins 21 | maven-fluido-skin 22 | 1.5 23 | 24 | 25 | 26 | true 27 | navbar-inverse 28 | true 29 | span2 30 | span10 31 | 32 | 33 | 34 | ${project.name} 35 | ${project.name} 36 | ../index.html 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /log4jna-demo/src/site/site.xml: -------------------------------------------------------------------------------- 1 | 2 | 15 | 18 | 19 | 20 | org.apache.maven.skins 21 | maven-fluido-skin 22 | 1.5 23 | 24 | 25 | 26 | true 27 | navbar-inverse 28 | true 29 | span2 30 | span10 31 | 32 | 33 | 34 | ${project.name} 35 | ${project.name} 36 | ../index.html 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /log4jna-api/src/site/site.xml: -------------------------------------------------------------------------------- 1 | 2 | 15 | 18 | 19 | 20 | org.apache.maven.skins 21 | maven-fluido-skin 22 | 1.5 23 | 24 | 25 | 26 | true 27 | navbar-inverse 28 | true 29 | span2 30 | span10 31 | 32 | 33 | 34 | ${project.name} 35 | ${project.name} 36 | ../index.html 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /log4jna-win32dll/README.md: -------------------------------------------------------------------------------- 1 | # Win32EventLogAppender.dll 2 | 3 | The Win32EventLogAppender.dll can be built either with Microsoft Visual C or GCC using MinGW on UN*X or Windows. 4 | 5 | To build on Windows with GCC download [MinGW](https://mingw.osdn.io/). 6 | 7 | The ant `build.xml` script is designed to be run via [Maven](http://maven.apache.org/) and the 8 | [`maven-ant-run-plugin`](http://maven.apache.org/plugins/maven-antrun-plugin/) associated to the `compile` goal. 9 | 10 | The default build environment is driven by Maven profiles that are activated by the os family attribute. In windows environments it defaults 11 | to Visual C++ and in Linux/Un*x it defaults to GCC MinGW32. 12 | 13 | ## Building in Windows 14 | ### Building with MS Visual C 15 | Execute the appropriate `vcvars[32 | 64 | all]` or launch a developer command line. See 16 | [this](https://msdn.microsoft.com/en-us/library/f2ccy3wt.aspx) for more on Visual C command line. 17 | 18 | To build use your IDE or run `mvn clean compile` or any goal that will include compile like `deploy` or `package`. 19 | 20 | ### Building with MinGW and gcc 21 | Install MinGW and add `\bin` to your `PATH` variable. 22 | 23 | To build configure your IDE to launch Maven with the 'mwbuild' profile, or run `mvn clean compile -P mwbuild` or any goal that will include 24 | compile like `deploy` or `package`. 25 | 26 | ## Building in Linux/Un*x 27 | ### Building with MinGW and gcc 28 | 29 | Install MinGW32 and add `\bin' to your `PATH` variable. 30 | 31 | To build use your IDE or run `mvn clean compile` or any goal that will include compile like `deploy` or `package`. 32 | 33 | ### Building with Visual C 34 | 35 | **NOTE: We do not support nor have tested building this option** 36 | 37 | Theoretically you should be able to do this with **mono**. Configure `mono` and install Visual C tools. 38 | 39 | To build configure your IDE to launch Maven with the 'msbuild' profile, or run `mvn clean compile -P msbuild` or any goal that will include 40 | compile like `deploy` or `package`. 41 | 42 | -------------------------------------------------------------------------------- /log4jna-api/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | log4jna-api 4 | Log4JNA Api 5 | Logger appender implementation to Write to Windows Event Logger. 6 | https://github.com/dblock/log4jna 7 | 8 | org.dblock.log4jna 9 | 2.1.1-SNAPSHOT 10 | log4jna 11 | ../ 12 | 13 | 14 | 15 | org.apache.logging.log4j 16 | log4j-core 17 | 18 | 19 | net.java.dev.jna 20 | jna-platform 21 | 22 | 23 | 24 | 25 | 26 | maven-compiler-plugin 27 | 28 | 29 | 30 | 31 | 32 | 33 | org.apache.maven.plugins 34 | maven-project-info-reports-plugin 35 | 3.5.0 36 | 37 | true 38 | 39 | 40 | 41 | 42 | index 43 | dependencies 44 | dependency-management 45 | dependency-info 46 | plugin-management 47 | plugins 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /log4jna-win32dll/src/site/markdown/index.md: -------------------------------------------------------------------------------- 1 | # Win32EventLogAppender.dll 2 | 3 | The Win32EventLogAppender.dll can be built either with Microsoft Visual C or GCC using MinGW on UN*X or Windows. 4 | 5 | To build on Windows with GCC download [MinGW](https://mingw.osdn.io/). 6 | 7 | The ant `build.xml` script is designed to be run via [Maven](http://maven.apache.org/) and the 8 | [`maven-ant-run-plugin`](http://maven.apache.org/plugins/maven-antrun-plugin/) associated to the `compile` goal. 9 | 10 | The default build environment is driven by Maven profiles that are activated by the os family attribute. In windows environments it defaults 11 | to Visual C++ and in Linux/Un*x it defaults to GCC MinGW32. 12 | 13 | ## Building in Windows 14 | ### Building with MS Visual C 15 | Execute the appropriate `vcvars[32 | 64 | all]` or launch a developer command line. See 16 | [this](https://msdn.microsoft.com/en-us/library/f2ccy3wt.aspx) for more on Visual C command line. 17 | 18 | To build use your IDE or run `mvn clean compile` or any goal that will include compile like `deploy` or `package`. 19 | 20 | ### Building with MinGW and gcc 21 | Install MinGW and add `\bin` to your `PATH` variable. 22 | 23 | To build configure your IDE to launch Maven with the 'mwbuild' profile, or run `mvn clean compile -P mwbuild` or any goal that will include 24 | compile like `deploy` or `package`. 25 | 26 | ## Building in Linux/Un*x 27 | ### Building with MinGW and gcc 28 | 29 | Install MinGW32 and add `\bin' to your `PATH` variable. 30 | 31 | To build use your IDE or run `mvn clean compile` or any goal that will include compile like `deploy` or `package`. 32 | 33 | ### Building with Visual C 34 | 35 | **NOTE: We do not support nor have tested building this option** 36 | 37 | Theoretically you should be able to do this with **mono**. Configure `mono` and install Visual C tools. 38 | 39 | To build configure your IDE to launch Maven with the 'msbuild' profile, or run `mvn clean compile -P msbuild` or any goal that will include 40 | compile like `deploy` or `package`. 41 | 42 | -------------------------------------------------------------------------------- /log4jna-assembly/src/main/resources/demo/log4j2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 23 | 26 | 27 | 32 | 35 | 36 | Win32EventLogAppender.dll 37 | 38 | 39 | 40 | 41 | 43 | 44 | 45 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /log4jna-doc/org.apache.log4jna.nt.Win32EventLogAppender.md: -------------------------------------------------------------------------------- 1 | Files 2 | ===== 3 | 4 | Include *log4jna.jar*, *jna.jar* and *platform.jar* in your application. If you're logging under a web server, JNA files (*jna.jar* and *platform.jar*) should be placed in a parent classloader such as Tomcat's lib directory. 5 | 6 | Properties 7 | ========== 8 | 9 | log4j.appender.A=org.apache.log4jna.nt.Win32EventLogAppender 10 | log4j.appender.A.source=Log4jna 11 | log4j.appender.A.layout=org.apache.log4j.PatternLayout 12 | log4j.appender.A.layout.ConversionPattern=%d{EEE dd MMM HH:mm:ss} - %m%n 13 | 14 | Registry 15 | ======== 16 | 17 | In order to get properly formatted messages in the event log, create `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\eventlog\Application\Log4jna` with the values of `EventMessageFile` and `CategoryMessageFile` pointing to the location of *Win32EventLogAppender.dll* (eg. `c:\Program Files\MyApplication\Win32EventLogAppender.dll`) and the values of `TypesSupported = 7` and `CategoryCount = 6`. Note that unlike log4j's NTEventLogAppender, this DLL only contains message formats and you do not need to place it in the system directory. 18 | 19 | ![org.apache.log4jna.nt.Win32EventLogAppender registry](org.apache.log4jna.nt.Win32EventLogAppender.registry.png?raw=true "Registry") 20 | 21 | The Log4jna value above is the name of your event source. This can be changed by defining the appender's source property. 22 | 23 | Creating this registry key is typically done in your application's installer. Log4jna will attempt to create it if it doesn't exist, but won't know where to find the *Win32EventLogAppender.dll*. This will cause the Event Viewer to be confused and include a warning about not finding the message resource. Messages will still be logged and display. 24 | 25 | FAQ 26 | === 27 | 28 | * [log4j:ERROR Could not register event source (Access is denied.)](http://code.dblock.org/log4jna-log4jerror-could-not-register-event-source-access-is-denied) 29 | * [The description for Event ID 4096 from source log4jna cannot be found.](http://code.dblock.org/log4jna-the-description-for-event-id-4096-from-source-log4jna-cannot-be-found) -------------------------------------------------------------------------------- /log4jna-demo/src/test/resources/log4j2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 23 | 26 | 27 | 32 | 35 | 36 | src\test\resources\Win32EventLogAppender.dll 37 | 38 | 39 | 40 | 41 | 43 | 44 | 45 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /log4jna-demo/src/main/resources/log4j2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 23 | 26 | 27 | 32 | 35 | 36 | src\test\resources\Win32EventLogAppender.dll 37 | 38 | 39 | 40 | 41 | 43 | 44 | 45 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /.github/workflows/Release.yml: -------------------------------------------------------------------------------- 1 | name: Log4JNA Release 2 | 3 | on: 4 | workflow_dispatch: 5 | 6 | jobs: 7 | build: 8 | strategy: 9 | matrix: 10 | entry: 11 | - { java: "11", distribution: "temurin" } 12 | 13 | runs-on: "windows-2019" 14 | 15 | name: Java ${{ matrix.entry.java }} ( ${{ matrix.entry.distribution }} ) 16 | steps: 17 | # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it 18 | - uses: actions/checkout@v3 19 | 20 | # Configuring Developer Command Prompt for Microsoft Visual C++ 21 | - uses: ilammy/msvc-dev-cmd@v1 22 | 23 | # Setup JDK 24 | - uses: actions/setup-java@v3 25 | with: 26 | distribution: ${{ matrix.entry.distribution }} 27 | java-version: ${{ matrix.entry.java }} 28 | server-id: central 29 | server-username: MAVEN_CENTRAL_USERNAME 30 | server-password: MAVEN_CENTRAL_PASSWORD 31 | gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} 32 | gpg-passphrase: MAVEN_GPG_PASSPHRASE 33 | 34 | # Set git config 35 | - run: | 36 | git config --global user.name github-actions[bot] 37 | git config --global user.email 41898282+github-actions[bot]@users.noreply.github.com 38 | 39 | # Prepare Release 40 | - run: mvn clean release:prepare -P release 41 | env: 42 | MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }} 43 | MAVEN_CENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }} 44 | MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }} 45 | GITHUB_USERNAME: ${{ secrets.GIT_USERNAME }} 46 | GITHUB_TOKEN: ${{ secrets.GIT_ACCESS_TOKEN }} 47 | 48 | # Perform Release 49 | - run: mvn clean release:perform -P release 50 | env: 51 | MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }} 52 | MAVEN_CENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }} 53 | MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }} 54 | GITHUB_USERNAME: ${{ secrets.GIT_USERNAME }} 55 | GITHUB_TOKEN: ${{ secrets.GIT_ACCESS_TOKEN }} 56 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 2.1.1 (Next) 2 | ------------ 3 | 4 | * Your contribution here. 5 | 6 | 2.1.0 (2022/07/15) 7 | ------------------ 8 | 9 | * [#50](https://github.com/dblock/log4jna/pull/50): Upgrade to JNA 5.9.0 - [@shamus13](https://github.com/shamus13). 10 | * [#51](https://github.com/dblock/log4jna/pull/51): Migrate from AppVeyor to GitHub Actions. - [@yokra9](https://github.com/yokra9). 11 | * [#84](https://github.com/dblock/log4jna/pull/84): Fix levels mapping - [@MacTrophy](https://github.com/MacTrophy) and [@yokra9](https://github.com/yokra9). 12 | 13 | 2.0 (2016/8/8) 14 | -------------- 15 | 16 | * [#6](https://github.com/dblock/log4jna/issues/6): Distribute to Maven Central 17 | * [#8](https://github.com/dblock/log4jna/pull/8): Upgrade to log4j2 - [@cstorey](https://github.com/cstorey). 18 | * [#9](https://github.com/dblock/log4jna/pull/9): Mavenized build - [@claudiow](https://github.com/claudiow). 19 | * [#9](https://github.com/dblock/log4jna/pull/9): Added Log4j 2 configuration - [@claudiow](https://github.com/claudiow). 20 | * [#19](https://github.com/dblock/log4jna/pull/19): Changed project to org.dblock.log4jna - [@claudiow](https://github.com/claudiow). 21 | 22 | 1.3 (2014/3/5) 23 | -------------- 24 | 25 | * [#3](https://github.com/dblock/log4jna/pull/3): Allow setting of an application name as log4j parameters - [@tonyniemira](https://github.com/tonyniemira). 26 | * [#3](https://github.com/dblock/log4jna/pull/3): Allow setting of an event and category message file - [@tonyniemira](https://github.com/tonyniemira). 27 | * [#3](https://github.com/dblock/log4jna/pull/3): Re-throw `Win32Exception` when failing to deregister the event source - [@tonyniemira](https://github.com/tonyniemira). 28 | 29 | 1.2 (2013/5/26) 30 | --------------- 31 | 32 | * [#2](https://github.com/dblock/log4jna/pull/2): Added ability to change the log name - [@marmstrong](https://github.com/marmstrong). 33 | 34 | 1.1 (2012/6/13) 35 | --------------- 36 | 37 | * [#1](https://github.com/dblock/log4jna/pull/1): Using error handler instead of throwing exceptions - [@kjeldahl](https://github.com/kjeldahl). 38 | 39 | 1.0 (2010/9/28) 40 | --------------- 41 | 42 | * Initial public release - [@dblock](https://github.com/dblock) 43 | -------------------------------------------------------------------------------- /log4jna-demo/src/test/resources/log4j2-application.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 23 | 26 | 27 | 32 | 35 | 36 | 37 | C:\Users\claudiow\git\log4jna\src\main\resources\Win32EventLogAppender.dll 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /log4jna-win32dll/src/Win32EventLogAppender.rc: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to the Apache Software Foundation (ASF) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. The ASF licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | // 20 | // Message file include 21 | // 22 | LANGUAGE 0x9,0x1 23 | 1 11 MSG00001.bin 24 | // Microsoft Visual C++ generated resource script. 25 | // 26 | #include "windows.h" 27 | 28 | #define APSTUDIO_READONLY_SYMBOLS 29 | ///////////////////////////////////////////////////////////////////////////// 30 | // 31 | // Generated from the TEXTINCLUDE 2 resource. 32 | // 33 | //#include "afxres.h" 34 | 35 | ///////////////////////////////////////////////////////////////////////////// 36 | #undef APSTUDIO_READONLY_SYMBOLS 37 | 38 | ///////////////////////////////////////////////////////////////////////////// 39 | // English (U.S.) resources 40 | 41 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) 42 | #ifdef _WIN32 43 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US 44 | #pragma code_page(1252) 45 | #endif //_WIN32 46 | 47 | #ifdef APSTUDIO_INVOKED 48 | ///////////////////////////////////////////////////////////////////////////// 49 | // 50 | // TEXTINCLUDE 51 | // 52 | 53 | 1 TEXTINCLUDE 54 | BEGIN 55 | "resource.h\0" 56 | END 57 | 58 | 2 TEXTINCLUDE 59 | BEGIN 60 | "#include ""afxres.h""\r\n" 61 | "\0" 62 | END 63 | 64 | 3 TEXTINCLUDE 65 | BEGIN 66 | "\r\n" 67 | "\0" 68 | END 69 | 70 | #endif // APSTUDIO_INVOKED 71 | 72 | 73 | ///////////////////////////////////////////////////////////////////////////// 74 | // 75 | // Version 76 | // 77 | 78 | #include "version.rc" 79 | 80 | #endif // English (U.S.) resources 81 | ///////////////////////////////////////////////////////////////////////////// 82 | 83 | 84 | 85 | #ifndef APSTUDIO_INVOKED 86 | ///////////////////////////////////////////////////////////////////////////// 87 | // 88 | // Generated from the TEXTINCLUDE 3 resource. 89 | // 90 | 91 | 92 | ///////////////////////////////////////////////////////////////////////////// 93 | #endif // not APSTUDIO_INVOKED 94 | 95 | -------------------------------------------------------------------------------- /log4jna-assembly/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | log4jna-assembly 4 | Log4JNA Assembly 5 | pom 6 | 7 | org.dblock.log4jna 8 | 2.1.1-SNAPSHOT 9 | log4jna 10 | ../ 11 | 12 | 13 | 14 | org.apache.logging.log4j 15 | log4j-core 16 | 17 | 18 | net.java.dev.jna 19 | jna-platform 20 | 21 | 22 | 23 | 24 | 25 | maven-assembly-plugin 26 | 27 | 28 | src/main/resources/log4jna-assembly.xml 29 | 30 | ${project.name}-${project.version} 31 | false 32 | 33 | 34 | 35 | make-src-assembly 36 | package 37 | 38 | single 39 | 40 | 41 | 42 | src/main/resources/sources-assembly.xml 43 | 44 | sources 45 | false 46 | 47 | 48 | 49 | make-demo-assembly 50 | package 51 | 52 | single 53 | 54 | 55 | 56 | src/main/resources/run-demo-assembly.xml 57 | 58 | run-demo 59 | false 60 | 61 | 62 | 63 | make-assembly 64 | package 65 | 66 | single 67 | 68 | 69 | 70 | 71 | 72 | 73 | A ziped file with all what you need to run or build log4jna 74 | -------------------------------------------------------------------------------- /log4jna-assembly/src/main/resources/log4jna-assembly.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | log4jna 5 | 6 | zip 7 | 8 | false 9 | 10 | 11 | 12 | ..\log4jna-assembly\target 13 | false 14 | true 15 | \ 16 | 17 | archive-tmp\**\*.* 18 | ${project.name}-${project.version}\**\*.* 19 | 20 | 21 | sources.zip 22 | run-demo.zip 23 | 24 | 25 | 26 | 27 | 28 | ..\log4jna-doc 29 | false 30 | true 31 | \doc 32 | 33 | **\*.* 34 | 35 | 36 | .project 37 | 38 | 39 | 40 | ..\target\staging 41 | false 42 | true 43 | doc\maven-site\ 44 | 45 | **\*.* 46 | 47 | 48 | 49 | 50 | ..\log4jna-win32dll\target 51 | false 52 | true 53 | \ 54 | 55 | Win32EventLogAppender.dll 56 | 57 | 58 | 59 | 60 | ..\log4jna-api\target 61 | false 62 | true 63 | \ 64 | 65 | *.jar 66 | 67 | 68 | 69 | ..\log4jna-demo\target 70 | false 71 | true 72 | \log4jna-demo 73 | 74 | *.jar 75 | 76 | 77 | 78 | 79 | 80 | /lib 81 | true 82 | 83 | *:jar:* 84 | 85 | 86 | 87 | -------------------------------------------------------------------------------- /log4jna-demo/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | org.dblock.log4jna 5 | log4jna 6 | 2.1.1-SNAPSHOT 7 | ../ 8 | 9 | log4jna-demo 10 | Log4JNA Demo 11 | https://github.com/dblock/log4jna/tree/master/demo 12 | Demonstrates the usage of Log4JNA 13 | 14 | 15 | org.dblock.log4jna 16 | log4jna-api 17 | 2.1.1-SNAPSHOT 18 | 19 | 20 | 22 | 23 | 24 | 25 | 26 | maven-compiler-plugin 27 | 28 | 1.8 29 | 1.8 30 | 31 | 32 | 33 | org.apache.maven.plugins 34 | maven-jar-plugin 35 | 36 | 37 | 38 | true 39 | org.apache.log4jna.nt.demo.NewDemo 40 | 41 | 42 | 43 | 44 | 45 | org.apache.maven.plugins 46 | maven-assembly-plugin 47 | 48 | 49 | 50 | single 51 | 52 | package 53 | 54 | 55 | jar-with-dependencies 56 | 57 | 58 | 59 | true 60 | org.apache.log4jna.nt.demo.NewDemo 61 | 62 | 63 | 64 | jar 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | org.apache.maven.plugins 76 | maven-project-info-reports-plugin 77 | 3.5.0 78 | 79 | true 80 | 81 | 82 | 83 | 84 | index 85 | dependencies 86 | dependency-management 87 | dependency-info 88 | plugin-management 89 | plugins 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![Log4JNA](https://github.com/dblock/log4jna/raw/master/log4jna.jpg?raw=true "Log4JNA") 2 | [![Gitter](https://badges.gitter.im/dblock/log4jna.svg)](https://gitter.im/dblock/log4jna?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) 3 | [![Build status](https://github.com/dblock/log4jna/actions/workflows/Default.yml/badge.svg)](https://github.com/dblock/log4jna/actions/workflows/Default.yml) 4 | [![Maven Central](https://img.shields.io/maven-central/v/org.dblock.log4jna/log4jna)](https://search.maven.org/artifact/org.dblock.log4jna/log4jna) 5 | 6 | Log4JNA is a library of native appenders to write into WindowsTM Event Viewer for [Log4j 2TM](http://logging.apache.org/log4j/). 7 | 8 | Unlike the native implementation(s) in Log4jTM, this project uses [JNA](http://github.com/twall/jna) and therefore does not require a native DLL in a system directory or on PATH. 9 | 10 | **Note:** Log4JNA is intended for WindowTM environments and requires access to WindowsTM registry and Event Viewer, therefore can only be tested in WindowsTM environments 11 | 12 | ## Using Log4JNA 13 | 14 | #### Getting Log4JNA 15 | 16 | See the [Downloads](#dw) section bellow to get Log4JNA. 17 | 18 | See [Maven, Ivy, and Gradle Artifacts](MAVENIVYGRADLE.md) to include Log4JNA from Maven Central 19 | 20 | #### Using Log4JNA 21 | 22 | See [Log4JNA configuration](USAGE.md) for instructions and tips. 23 | 24 | See the [FAQ](FAQ.md) for common problems and solutions. 25 | 26 | ## Developing Log4JNA 27 | See [Contributing](CONTRIBUTING.md) for a primer on how to help on Log4JNA development. 28 | 29 | See [Development Environment Set Up](ENVIRONMENT.md) for some tips and requirements before starting. 30 | 31 | ## Downloads 32 | #### Log4JNA 2 for Log4j 2.x 33 | 34 | | Current Release | Latest Development | 35 | | ------------- |------------- | 36 | | [Log4jna Api 2.1.0](https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=org.dblock.log4jna&a=log4jna-api&v=2.1.0&e=jar) | [Log4JNA Api 2.1.1-SNAPSHOT](https://oss.sonatype.org/service/local/artifact/maven/redirect?r=snapshots&g=org.dblock.log4jna&a=log4jna-api&v=2.1.1-SNAPSHOT&e=jar) | 37 | | [Log4jna Demo 2.1.0](https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=org.dblock.log4jna&a=log4jna-demo&v=2.1.0&e=jar) | [Log4JNA Demo 2.1.1-SNAPSHOT](https://oss.sonatype.org/service/local/artifact/maven/redirect?r=snapshots&g=org.dblock.log4jna&a=log4jna-demo&v=2.1.1-SNAPSHOT&e=jar) | 38 | | [Log4jna Demo with dependencies 2.1.0](https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=org.dblock.log4jna&a=log4jna-demo&v=2.1.0&e=jar) | [Log4jna Demo with dependencies 2.1.1-SNAPSHOT](https://oss.sonatype.org/service/local/artifact/maven/redirect?r=snapshots&g=org.dblock.log4jna&a=log4jna-demo&v=2.1.1-SNAPSHOT&c=jar-with-dependencies&e=jar) | 39 | | [Log4jna Zip 2.1.0 (Jars, Sources, Dependencies and Documentation)](https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=org.dblock.log4jna&a=log4jna-assembly&v=2.1.0&e=zip) | [Log4jna Zip 2.1.1-SNAPSHOT (Jars, Sources, Dependencies and Documentation)](https://oss.sonatype.org/service/local/artifact/maven/redirect?r=snapshots&g=org.dblock.log4jna&a=log4jna-assembly&v=2.1.1-SNAPSHOT&e=zip) | 40 | 41 | #### Log4JNA for Log4j 1.x 42 | * [log4jna-1.3.zip](http://code.dblock.org/downloads/log4jna/log4jna-1.3.zip) 43 | 44 | 45 | * [org.apache.log4jna.nt.Win32EventLogAppender](log4jna-doc/org.apache.log4jna.nt.Win32EventLogAppender.md): a replacement for NTEventLogAppender based on JNA that doesn't require a native DLL in a system directory. 46 | 47 | 48 | License 49 | ------- 50 | This project is licensed under the [Apache Software Foundation 2.0 License](http://www.apache.org/licenses/LICENSE-2.0) 51 | 52 | -------------------------------------------------------------------------------- /src/site/markdown/index.md: -------------------------------------------------------------------------------- 1 | ![Log4JNA](https://github.com/dblock/log4jna/raw/master/log4jna.jpg?raw=true "Log4JNA") 2 | [![Gitter](https://badges.gitter.im/dblock/log4jna.svg)](https://gitter.im/dblock/log4jna?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) 3 | [![Build status](https://github.com/dblock/log4jna/actions/workflows/Default.yml/badge.svg)](https://github.com/dblock/log4jna/actions/workflows/Default.yml) 4 | [![Maven Central](https://img.shields.io/maven-central/v/org.dblock.log4jna/log4jna)](https://search.maven.org/artifact/org.dblock.log4jna/log4jna) 5 | 6 | Log4JNA is a library of native appenders to write into WindowsTM Event Viewer for [Log4j 2TM](http://logging.apache.org/log4j/). 7 | 8 | Unlike the native implementation(s) in Log4jTM, this project uses [JNA](http://github.com/twall/jna) and therefore does not require a native DLL in a system directory or on PATH. 9 | 10 | **Note:** Log4JNA is intended for WindowTM environments and requires access to WindowsTM registry and Event Viewer, therefore can only be tested in WindowsTM environments 11 | 12 | ## Using Log4JNA 13 | 14 | #### Getting Log4JNA 15 | 16 | See the [Downloads](#dw) section bellow to get Log4JNA. 17 | 18 | See [Maven, Ivy, and Gradle Artifacts](MAVENIVYGRADLE.md) to include Log4JNA from Maven Central 19 | 20 | #### Using Log4JNA 21 | 22 | See [Log4JNA configuration](USAGE.md) for instructions and tips. 23 | 24 | See the [FAQ](FAQ.md) for common problems and solutions. 25 | 26 | ## Developing Log4JNA 27 | See [Contributing](CONTRIBUTING.md) for a primer on how to help on Log4JNA development. 28 | 29 | See [Development Environment Set Up](ENVIRONMENT.md) for some tips and requirements before starting. 30 | 31 | ## Downloads 32 | #### Log4JNA 2 for Log4j 2.x 33 | 34 | | Current Release | Latest Development | 35 | | ------------- |------------- | 36 | | [Log4jna Api 2.1.0](https://oss.sonatype.org/service/local/repositories/releases/content/org/dblock/log4jna/log4jna-api/2.1.0/log4jna-api-2.1.0.jar) | [Log4JNA Api 2.1.1-SNAPSHOT](https://oss.sonatype.org/service/local/artifact/maven/redirect?r=snapshots&g=org.dblock.log4jna&a=log4jna-api&v=2.1.1-SNAPSHOT&e=jar) | 37 | | [Log4jna Demo 2.1.0](https://oss.sonatype.org/service/local/repositories/releases/content/org/dblock/log4jna/log4jna-demo/2.1.0/log4jna-demo-2.1.0.jar) | [Log4JNA Demo 2.1.1-SNAPSHOT](https://oss.sonatype.org/service/local/artifact/maven/redirect?r=snapshots&g=org.dblock.log4jna&a=log4jna-demo&v=2.1.1-SNAPSHOT&e=jar) | 38 | | [Log4jna Demo with dependencies 2.1.0](https://oss.sonatype.org/service/local/repositories/releases/content/org/dblock/log4jna/log4jna-demo/2.1.0/log4jna-demo-2.1.0-jar-with-dependencies.jar) | [Log4jna Demo with dependencies 2.1.1-SNAPSHOT](https://oss.sonatype.org/service/local/artifact/maven/redirect?r=snapshots&g=org.dblock.log4jna&a=log4jna-demo&v=2.1.1-SNAPSHOT&c=jar-with-dependencies&e=jar) | 39 | | [Log4jna Zip 2.1.0 (Jars, Sources, Dependencies and Documentation)](https://oss.sonatype.org/service/local/repositories/releases/content/org/dblock/log4jna/log4jna-assembly/2.1.0/log4jna-assembly-2.1.0.zip) | [Log4jna Zip 2.1.1-SNAPSHOT (Jars, Sources, Dependencies and Documentation)](https://oss.sonatype.org/service/local/artifact/maven/redirect?r=snapshots&g=org.dblock.log4jna&a=log4jna-assembly&v=2.1.1-SNAPSHOT&e=zip) | 40 | 41 | #### Log4JNA for Log4j 1.x 42 | * [log4jna-1.3.zip](http://code.dblock.org/downloads/log4jna/log4jna-1.3.zip) 43 | 44 | 45 | * [org.apache.log4jna.nt.Win32EventLogAppender](log4jna-doc/org.apache.log4jna.nt.Win32EventLogAppender.md): a replacement for NTEventLogAppender based on JNA that doesn't require a native DLL in a system directory. 46 | 47 | 48 | License 49 | ------- 50 | This project is licensed under the [Apache Software Foundation 2.0 License](http://www.apache.org/licenses/LICENSE-2.0) 51 | 52 | -------------------------------------------------------------------------------- /src/site/site.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 9 | 10 | 11 | org.apache.maven.skins 12 | maven-fluido-skin 13 | 1.5 14 | 15 | 16 | 17 | true 18 | navbar-inverse 19 | true 20 | span2 21 | span10 22 | true 23 | 24 | 25 | 26 | ${project.name} 27 | ${project.name} 28 | ../index.html 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /log4jna-demo/src/main/java/org/dblock/log4jna/nt/demo/NewDemo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache license, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with 4 | * the License. You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the license for the specific language governing permissions and 12 | * limitations under the license. 13 | */ 14 | package org.dblock.log4jna.nt.demo; 15 | 16 | import org.apache.logging.log4j.LogManager; 17 | import org.apache.logging.log4j.Logger; 18 | 19 | /** 20 | * A new more extended demo application based on Demo.java by Ceri Storey. 21 | * 22 | *

23 | * Note: To run for the first time you must be Administrator in Windows. 24 | * This application needs to write the registry when run for the first time 25 | *

26 | * 27 | * @author Claudio Trajtenberg 28 | * @author Daniel Doubrovkine 29 | * @author Ceri Storey 30 | */ 31 | public class NewDemo { 32 | 33 | private static Logger LOGGER = LogManager.getLogger(); 34 | 35 | private static final String MSG = "NewDemo: %s"; 36 | 37 | /** 38 | * @param args 39 | */ 40 | public static void main(String[] args) { 41 | NewDemo d = new NewDemo(); 42 | 43 | d.trace(); 44 | d.debug(); 45 | d.info(); 46 | d.warn(); 47 | d.error(); 48 | d.fatal(); 49 | d.warnWithException(); 50 | d.errorWithException(); 51 | d.fatalWithException(); 52 | } 53 | 54 | /** 55 | * 56 | */ 57 | public void trace() { 58 | LOGGER.trace(String.format(MSG, "Enter trace")); 59 | LOGGER.trace(String.format(MSG, "Exit trace")); 60 | } 61 | 62 | /** 63 | * 64 | */ 65 | public void debug() { 66 | LOGGER.debug(String.format(MSG, "Enter debug")); 67 | LOGGER.debug(String.format(MSG, "Exit debug")); 68 | } 69 | 70 | /** 71 | * 72 | */ 73 | public void info() { 74 | LOGGER.info(String.format(MSG, "Enter info")); 75 | LOGGER.info(String.format(MSG, "Exit info")); 76 | } 77 | 78 | /** 79 | * 80 | */ 81 | public void warn() { 82 | LOGGER.warn(String.format(MSG, "Enter warn")); 83 | LOGGER.warn(String.format(MSG, "Exit warn")); 84 | } 85 | 86 | /** 87 | * 88 | */ 89 | public void error() { 90 | LOGGER.error(String.format(MSG, "Enter error")); 91 | LOGGER.error(String.format(MSG, "Exit error")); 92 | } 93 | 94 | /** 95 | * 96 | */ 97 | public void fatal() { 98 | LOGGER.fatal(String.format(MSG, "Enter fatal")); 99 | LOGGER.fatal(String.format(MSG, "Exit fatal")); 100 | } 101 | 102 | /** 103 | * 104 | */ 105 | public void warnWithException() { 106 | try { 107 | throwException(); 108 | } catch (Exception e) { 109 | LOGGER.warn(String.format(MSG, "In warn with exception"), e); 110 | } 111 | } 112 | 113 | /** 114 | * @throws Exception 115 | */ 116 | private void throwException() throws Exception { 117 | throw new Exception("Pouporselly thrown for demo"); 118 | 119 | } 120 | 121 | /** 122 | * 123 | */ 124 | public void errorWithException() { 125 | try { 126 | throwException(); 127 | } catch (Throwable e) { 128 | LOGGER.error(String.format(MSG, "In error with exception"), e); 129 | } 130 | } 131 | 132 | /** 133 | * 134 | */ 135 | public void fatalWithException() { 136 | try { 137 | throwException(); 138 | } catch (Throwable e) { 139 | LOGGER.fatal(String.format(MSG, "In fatal with exception"), e); 140 | } 141 | } 142 | } 143 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | Contributing to Log4JNA 2 | ===================== 3 | 4 | Log4JNA is work of [many contributors](https://github.com/dblock/log4jna/graphs/contributors). You're encouraged to submit [pull requests](https://github.com/dblock/log4jna/pulls), [propose features and discuss issues](https://github.com/dblock/log4jna/issues). 5 | 6 | #### Fork the Project 7 | 8 | Fork the [project on Github](https://github.com/dblock/log4jna) and check out your copy. 9 | 10 | ``` 11 | git clone https://github.com/contributor/log4jna.git 12 | cd log4jna 13 | git remote add upstream https://github.com/dblock/log4jna.git 14 | ``` 15 | 16 | #### Create a Topic Branch 17 | 18 | Make sure your fork is up-to-date and create a topic branch for your feature or bug fix. 19 | 20 | ``` 21 | git checkout master 22 | git pull upstream master 23 | git checkout -b my-feature-branch 24 | ``` 25 | 26 | #### Build and Test 27 | 28 | Ensure that you can build the project and run tests. 29 | 30 | ``` 31 | mvn test 32 | ``` 33 | 34 | ##### Notes on building 35 | 36 | See [Win32EventLogAppender README](log4jna-win32dll/README.md) for requirements on building the the message file. 37 | 38 | The build does not complain and skips the message file if it can't be build. 39 | 40 | #### Write Tests 41 | 42 | Try to write a test that reproduces the problem you're trying to fix or describes a feature that you want to build. 43 | 44 | We definitely appreciate pull requests that highlight or reproduce a problem, even without a fix. 45 | 46 | #### Write Code 47 | 48 | Implement your feature or bug fix. 49 | 50 | Make sure that `mvn test` completes without errors. 51 | 52 | #### Write Documentation 53 | 54 | Document any external behavior in the [README](README.md). 55 | 56 | #### Update Changelog 57 | 58 | Add a line to [CHANGELOG](CHANGELOG.md) under *Next Release*. Make it look like every other line, including your name and link to your Github account. 59 | 60 | #### Commit Changes 61 | 62 | Make sure git knows your name and email address: 63 | 64 | ``` 65 | git config --global user.name "Your Name" 66 | git config --global user.email "contributor@example.com" 67 | ``` 68 | 69 | Writing good commit logs is important. A commit log should describe what changed and why. 70 | 71 | ``` 72 | git add ... 73 | git commit 74 | ``` 75 | 76 | #### Push 77 | 78 | ``` 79 | git push origin my-feature-branch 80 | ``` 81 | 82 | #### Make a Pull Request 83 | 84 | Go to https://github.com/contributor/log4jna and select your feature branch. Click the 'Pull Request' button and fill out the form. Pull requests are usually reviewed within a few days. 85 | 86 | #### Rebase 87 | 88 | If you've been working on a change for a while, rebase with upstream/master. 89 | 90 | ``` 91 | git fetch upstream 92 | git rebase upstream/master 93 | git push origin my-feature-branch -f 94 | ``` 95 | 96 | #### Update CHANGELOG Again 97 | 98 | Update the [CHANGELOG](CHANGELOG.md) with the pull request number. A typical entry looks as follows. 99 | 100 | ``` 101 | * [#123](https://github.com/dblock/log4jna/pull/123): Created some new feature - [@contributor](https://github.com/contributor). 102 | ``` 103 | 104 | Amend your previous commit and force push the changes. 105 | 106 | ``` 107 | git commit --amend 108 | git push origin my-feature-branch -f 109 | ``` 110 | 111 | #### Check on Your Pull Request 112 | 113 | Go back to your pull request after a few minutes and see whether it passed muster with Travis-CI. Everything should look green, otherwise fix issues and amend your commit as described above. 114 | 115 | #### Be Patient 116 | 117 | It's likely that your change will not be merged and that the nitpicky maintainers will ask you to do more, or fix seemingly benign problems. Hang on there! 118 | 119 | #### Thank You 120 | 121 | Please do know that we really appreciate and value your time and work. We love you, really. 122 | -------------------------------------------------------------------------------- /src/site/markdown/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | Contributing to Log4JNA 2 | ===================== 3 | 4 | Log4JNA is work of [many contributors](https://github.com/dblock/log4jna/graphs/contributors). You're encouraged to submit 5 | [pull requests](https://github.com/dblock/log4jna/pulls), [propose features and discuss issues](https://github.com/dblock/log4jna/issues). 6 | 7 | #### Fork the Project 8 | 9 | Fork the [project on Github](https://github.com/dblock/log4jna) and check out your copy. 10 | 11 | ``` 12 | git clone https://github.com/contributor/log4jna.git 13 | cd log4jna 14 | git remote add upstream https://github.com/dblock/log4jna.git 15 | ``` 16 | 17 | #### Create a Topic Branch 18 | 19 | Make sure your fork is up-to-date and create a topic branch for your feature or bug fix. 20 | 21 | ``` 22 | git checkout master 23 | git pull upstream master 24 | git checkout -b my-feature-branch 25 | ``` 26 | 27 | #### Build and Test 28 | 29 | Ensure that you can build the project and run tests. 30 | 31 | ``` 32 | mvn test 33 | ``` 34 | 35 | ##### Notes on building 36 | 37 | See [Win32EventLogAppender README](log4jna-win32dll/README.md) for requirements on building the the message file. 38 | 39 | The build does not complain and skips the message file if it can't be build. 40 | 41 | #### Write Tests 42 | 43 | Try to write a test that reproduces the problem you're trying to fix or describes a feature that you want to build. 44 | 45 | We definitely appreciate pull requests that highlight or reproduce a problem, even without a fix. 46 | 47 | #### Write Code 48 | 49 | Implement your feature or bug fix. 50 | 51 | Make sure that `mvn test` completes without errors. 52 | 53 | #### Write Documentation 54 | 55 | Document any external behavior in the [README](README.md). 56 | 57 | #### Update Changelog 58 | 59 | Add a line to [CHANGELOG](CHANGELOG.md) under *Next Release*. Make it look like every other line, including your name and link to your Github account. 60 | 61 | #### Commit Changes 62 | 63 | Make sure git knows your name and email address: 64 | 65 | ``` 66 | git config --global user.name "Your Name" 67 | git config --global user.email "contributor@example.com" 68 | ``` 69 | 70 | Writing good commit logs is important. A commit log should describe what changed and why. 71 | 72 | ``` 73 | git add ... 74 | git commit 75 | ``` 76 | 77 | #### Push 78 | 79 | ``` 80 | git push origin my-feature-branch 81 | ``` 82 | 83 | #### Make a Pull Request 84 | 85 | Go to https://github.com/contributor/log4jna and select your feature branch. Click the 'Pull Request' button and fill out the form. Pull requests are usually reviewed within a few days. 86 | 87 | #### Rebase 88 | 89 | If you've been working on a change for a while, rebase with upstream/master. 90 | 91 | ``` 92 | git fetch upstream 93 | git rebase upstream/master 94 | git push origin my-feature-branch -f 95 | ``` 96 | 97 | #### Update CHANGELOG Again 98 | 99 | Update the [CHANGELOG](CHANGELOG.md) with the pull request number. A typical entry looks as follows. 100 | 101 | ``` 102 | * [#123](https://github.com/dblock/log4jna/pull/123): Created some new feature - [@contributor](https://github.com/contributor). 103 | ``` 104 | 105 | Amend your previous commit and force push the changes. 106 | 107 | ``` 108 | git commit --amend 109 | git push origin my-feature-branch -f 110 | ``` 111 | 112 | #### Check on Your Pull Request 113 | 114 | Go back to your pull request after a few minutes and see whether it passed muster with Travis-CI. Everything should look green, otherwise fix issues and amend your commit as described above. 115 | 116 | #### Be Patient 117 | 118 | It's likely that your change will not be merged and that the nitpicky maintainers will ask you to do more, or fix seemingly benign problems. Hang on there! 119 | 120 | #### Thank You 121 | 122 | Please do know that we really appreciate and value your time and work. We love you, really. 123 | -------------------------------------------------------------------------------- /src/site/markdown/ENVIRONMENT.md: -------------------------------------------------------------------------------- 1 | # Setting up your development environment 2 | 3 | The first time you run the test suite or any application using Log4JNA, Log4JNA attempts to write the necessary entries in 4 | WindowsTM Registry. If you don't have administrator privileges the run fails. 5 | 6 | ### Running the tests 7 | In order for the tests to pass you must run them as Administrator or set up the registry before your first run. 8 | 9 | Open a command window as administrator and execute `mvn test` 10 | 11 | If you are using an IDE launch it as Administrator import the Maven projects and run the tests. 12 | 13 | ### IDE Setup 14 | 15 | Please be careful and do not check IDE configuration files into GitHub, you can add the project to your IDE following the instructions bellow. 16 | 17 | Eclipse configuration files are already added to `.gitignore`, please add any configuration file created by your IDE to the ignore file. 18 | 19 | #### Eclipse 20 | See [this article](https://books.sonatype.com/m2eclipse-book/reference/creating-sect-importing-projects.html) to import the Maven projects. 21 | 22 | #### IteliJ IDEA 23 | See [this article](https://www.jetbrains.com/help/idea/2016.1/importing-project-from-maven-model.html) to import the Maven projects. 24 | 25 | #### NetBeans 26 | See [this article](http://wiki.netbeans.org/MavenBestPractices) to import the Maven projects. 27 | 28 | ### Set up the Registry manually 29 | #### For Log4JNA Api Tests 30 | 31 | The `Win32EventlogAppender.dll` file is provided in the source as a test asset in 32 | `/log4jna-api/src/test/resources` 33 | 34 | The tests configure Log4J programmatically and write into `Event Viewer-->Windows Logs-->Application` 35 | 36 | 1. Open `regedit` and browse to `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\Application\` 37 | 2. Right click and select `New Key`, name it `Log4jnaTest` 38 | 3. Add the following entries to `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\Application\Log4jnaTest` 39 | 40 | | Entry name | Entry Type | Value | 41 | | ------------------- | ---------- | ---------------------------------------- | 42 | | TypesSupported | DWORD (32 bit) Value (REG_DWORD) | 0x7 | 43 | | CategoryCount | DWORD (32 bit) Value (REG_DWORD) | 0x6 | 44 | | EventMessageFile | String Value (REG_SZ) | <Full path to>\Win32EventlogAppender.dll | 45 | | CategoryMessageFile | String Value (REG_SZ) | <Full path to>\Win32EventlogAppender.dll | 46 | 47 | The registry should look like this: 48 | 49 | ![Registry Img](img/registry1.png) 50 | 51 | #### For the Demo Application Tests 52 | The `Win32EventlogAppender.dll` and Log4J 2 configuration files are provided in the source as an application asset in 53 | `/log4jna-demo/src/main/resources` 54 | 55 | The default Log4J configuration is `log4j2.xml` and writes into `Event Viewer-->Application and Service Logs-->Win32LogApplication` 56 | 57 | 1. Open `regedit` and browse to `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\` 58 | 2. Right click and select `New Key`, name it `Win32LogApplication` 59 | 1. Add another key to `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\Win32LogApplication`, name it `WinLogger` 60 | 3. Add the following entries to `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\Win32LogApplication\WinLogger` 61 | 62 | | Entry name | Entry Type | Value | 63 | | ------------------- | ---------- | ---------------------------------------- | 64 | | TypesSupported | DWORD (32 bit) Value (REG_DWORD) | 0x7 | 65 | | CategoryCount | DWORD (32 bit) Value (REG_DWORD) | 0x6 | 66 | | EventMessageFile | String Value (REG_SZ) | <Full path to>\Win32EventlogAppender.dll | 67 | | CategoryMessageFile | String Value (REG_SZ) | <Full path to>\Win32EventlogAppender.dll | 68 | 69 | The registry should look like this: 70 | 71 | ![Registry Img](img/registry2.png) 72 | -------------------------------------------------------------------------------- /ENVIRONMENT.md: -------------------------------------------------------------------------------- 1 | # Setting Up Your Development Environment 2 | 3 | The first time you run the test suite or any application using Log4JNA, Log4JNA attempts to write the necessary entries in 4 | WindowsTM Registry. If you don't have Administrator privileges the run fails. 5 | 6 | ### Running Tests 7 | 8 | In order for the tests to pass you must run them as Administrator or set up the registry before your first run. 9 | 10 | Open a command window as administrator and execute `mvn test`. 11 | 12 | If you are using an IDE launch it as Administrator import the Maven projects and run the tests. 13 | 14 | ### IDE Setup 15 | 16 | Please be careful and do not check IDE configuration files into GitHub, you can add the project to your IDE following the instructions bellow. 17 | 18 | Eclipse configuration files are already added to `.gitignore`, please add any configuration file created by your IDE to the ignore file. 19 | 20 | #### Eclipse 21 | 22 | See [this article](https://books.sonatype.com/m2eclipse-book/reference/creating-sect-importing-projects.html) to import the Maven projects. 23 | 24 | #### IteliJ IDEA 25 | 26 | See [this article](https://www.jetbrains.com/help/idea/2016.1/importing-project-from-maven-model.html) to import the Maven projects. 27 | 28 | #### NetBeans 29 | 30 | See [this article](http://wiki.netbeans.org/MavenBestPractices) to import the Maven projects. 31 | 32 | ### Set up the Registry manually 33 | 34 | #### For Log4JNA Api Tests 35 | 36 | The `Win32EventlogAppender.dll` file is provided in the source as a test asset in 37 | `/log4jna-api/src/test/resources`. 38 | 39 | The tests configure Log4J programmatically and write into `Event Viewer-->Windows Logs-->Application`. 40 | 41 | 1. Open `regedit` and browse to `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\Application\` 42 | 2. Right click and select `New Key`, name it `Log4jnaTest` 43 | 3. Add the following entries to `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\Application\Log4jnaTest` 44 | 45 | | Entry name | Entry Type | Value | 46 | | ------------------- | ---------- | ---------------------------------------- | 47 | | TypesSupported | DWORD (32 bit) Value (REG_DWORD) | 0x7 | 48 | | CategoryCount | DWORD (32 bit) Value (REG_DWORD) | 0x6 | 49 | | EventMessageFile | String Value (REG_SZ) | <Full path to>\Win32EventlogAppender.dll | 50 | | CategoryMessageFile | String Value (REG_SZ) | <Full path to>\Win32EventlogAppender.dll | 51 | 52 | The registry should look like this: 53 | 54 | ![Registry Img](src/site/resources/img/registry1.png) 55 | 56 | #### For the Demo Application Tests 57 | 58 | The `Win32EventlogAppender.dll` and Log4J 2 configuration files are provided in the source as an application asset in 59 | `/log4jna-demo/src/main/resources`. 60 | 61 | The default Log4J configuration is `log4j2.xml` and writes into `Event Viewer-->Application and Service Logs-->Win32LogApplication`. 62 | 63 | 1. Open `regedit` and browse to `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\` 64 | 2. Right click and select `New Key`, name it `Win32LogApplication` 65 | 1. Add another key to `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\Win32LogApplication`, name it `WinLogger` 66 | 3. Add the following entries to `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\Win32LogApplication\WinLogger` 67 | 68 | | Entry name | Entry Type | Value | 69 | | ------------------- | ---------- | ---------------------------------------- | 70 | | TypesSupported | DWORD (32 bit) Value (REG_DWORD) | 0x7 | 71 | | CategoryCount | DWORD (32 bit) Value (REG_DWORD) | 0x6 | 72 | | EventMessageFile | String Value (REG_SZ) | <Full path to>\Win32EventlogAppender.dll | 73 | | CategoryMessageFile | String Value (REG_SZ) | <Full path to>\Win32EventlogAppender.dll | 74 | 75 | The registry should look like this: 76 | 77 | ![Registry Img](src/site/resources/img/registry2.png) 78 | -------------------------------------------------------------------------------- /log4jna-win32dll/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | log4jna-win32dll 4 | pom 5 | Log4JNA Win32dll 6 | 7 | org.dblock.log4jna 8 | log4jna 9 | 2.1.1-SNAPSHOT 10 | ../ 11 | 12 | 13 | src 14 | 15 | 16 | resources 17 | 18 | 19 | 20 | 21 | org.apache.maven.plugins 22 | maven-javadoc-plugin 23 | 24 | true 25 | 26 | 27 | 28 | org.apache.maven.plugins 29 | maven-clean-plugin 30 | 31 | 32 | 33 | src 34 | 35 | EventLogCategories.h 36 | EventLogCategories.rc 37 | MSG00001.bin 38 | version.rc 39 | Win32EventLogAppender.res 40 | 41 | 42 | 43 | 44 | 45 | 46 | org.apache.maven.plugins 47 | maven-antrun-plugin 48 | 3.1.0 49 | 50 | 51 | add-dll 52 | compile 53 | 54 | run 55 | 56 | false 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | org.apache.maven.plugins 71 | maven-source-plugin 72 | 73 | 74 | maven-assembly-plugin 75 | 76 | 77 | make-src-assembly 78 | package 79 | 80 | single 81 | 82 | 83 | 84 | src/main/resources/sources-assembly.xml 85 | 86 | ${project.artifactId}-sources-${project.version} 87 | false 88 | 89 | 90 | 91 | make-dll-assembly 92 | package 93 | 94 | single 95 | 96 | 97 | 98 | src/main/resources/dll-assembly.xml 99 | 100 | ${project.artifactId}-dll-${project.version} 101 | false 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | org.apache.maven.plugins 112 | maven-clean-plugin 113 | 114 | true 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | msbuild 123 | 124 | 125 | windows 126 | 127 | 128 | 129 | msbuild 130 | "" 131 | 132 | 133 | 134 | 135 | mwbuild 136 | 137 | 138 | unix 139 | 140 | 141 | 142 | mwbuild 143 | 144 | 145 | 146 | 147 | -------------------------------------------------------------------------------- /log4jna-win32dll/src/build.xml: -------------------------------------------------------------------------------- 1 | 20 | 21 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | ${mingw-prefix}windres could not be found or failed, Win32EventLogAppender.dll build skipped. 123 | 124 | 125 | 126 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | rc could not be found or failed, Win32EventLogAppender.dll build skipped. 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | -------------------------------------------------------------------------------- /log4jna-api/src/test/java/org/dnlock/log4jna/nt/test/Win32EventLogAppenderTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 3 | * use this file except in compliance with the License. You may obtain a copy 4 | * of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | package org.dnlock.log4jna.nt.test; 16 | 17 | import static org.junit.Assert.*; 18 | import java.io.Serializable; 19 | import java.nio.file.Path; 20 | import java.nio.file.Paths; 21 | 22 | import org.apache.logging.log4j.Level; 23 | import org.apache.logging.log4j.core.Filter; 24 | import org.apache.logging.log4j.core.Layout; 25 | import org.apache.logging.log4j.core.LogEvent; 26 | import org.apache.logging.log4j.core.impl.Log4jLogEvent; 27 | import org.apache.logging.log4j.core.layout.PatternLayout; 28 | import org.apache.logging.log4j.message.SimpleMessage; 29 | import org.dblock.log4jna.nt.Win32EventLogAppender; 30 | import org.junit.Before; 31 | import org.junit.Test; 32 | 33 | import com.sun.jna.platform.win32.Advapi32Util; 34 | import com.sun.jna.platform.win32.Advapi32Util.EventLogIterator; 35 | import com.sun.jna.platform.win32.Advapi32Util.EventLogRecord; 36 | import com.sun.jna.platform.win32.Advapi32Util.EventLogType; 37 | import com.sun.jna.platform.win32.Kernel32; 38 | import com.sun.jna.platform.win32.WinNT; 39 | import com.sun.jna.platform.win32.WinReg; 40 | 41 | /** 42 | * Test case for {@link Win32EventLogAppender}. 43 | * 44 | * @author Curt Arnold 45 | * @author Daniel Doubrovkine 46 | * @author Tony Niemira 47 | * @author Claudio Trajtenberg 48 | * 49 | */ 50 | public class Win32EventLogAppenderTest { 51 | 52 | /** 53 | * This must exist in the windows registry. 54 | *

55 | * Key: 56 | *

57 | *

58 | * HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\Application\Log4jnaTest 59 | *

60 | *

61 | * With entries: 62 | *

63 | * 64 | *
 65 | 	 * Name: TypesSupported 
 66 | 	 * Type: REG_DWORD 
 67 | 	 * Data: 0x7
 68 | 	 * 
 69 | 	 * Name: CategoryCount 
 70 | 	 * Type: REG_DWORD 
 71 | 	 * Data: 0x6
 72 | 	 * 
73 | */ 74 | private static final String TEST_LOGGER_NAME = "Log4jnaTest"; 75 | 76 | /** 77 | * The dll file location from the src/test/resources folder. 78 | */ 79 | private static String _eventLogAppenderDLL = Paths.get("src/test/resources/Win32EventlogAppender.dll") 80 | .toAbsolutePath().toString(); 81 | 82 | /** 83 | * Class under test 84 | */ 85 | private Win32EventLogAppender _eventLogAppender = null; 86 | 87 | /** 88 | * 89 | */ 90 | @Before 91 | public void setUp() { 92 | String source = null; 93 | String log = getClass().getName(); 94 | Layout layout = PatternLayout.newBuilder() 95 | .withPattern(PatternLayout.TTCC_CONVERSION_PATTERN).build(); 96 | 97 | Filter filter = null; 98 | _eventLogAppender = Win32EventLogAppender.createAppender("appenderName", null, source, log, _eventLogAppenderDLL, _eventLogAppenderDLL, layout, filter); 99 | _eventLogAppender.setSource(TEST_LOGGER_NAME); 100 | _eventLogAppender.setApplication("Application"); 101 | // _eventLogAppender.setCategoryMessageFile(_eventLogAppenderDLL); 102 | // _eventLogAppender.setEventMessageFile(_eventLogAppenderDLL); 103 | } 104 | 105 | /** 106 | * Test case for {@link Win32EventLogAppender#append(LogEvent)} with debug 107 | * level. 108 | */ 109 | @Test 110 | public void testDebugEvent() { 111 | String message = "log4jna debug message @ " + Kernel32.INSTANCE.GetTickCount(); 112 | _eventLogAppender.append(asLogEvent(message, Level.DEBUG)); 113 | expectEvent(message, Level.DEBUG, EventLogType.Informational); 114 | } 115 | 116 | /** 117 | * Test case for {@link Win32EventLogAppender#append(LogEvent)} with info 118 | * level. 119 | */ 120 | @Test 121 | public void testInfoEvent() { 122 | String message = "log4jna info message @ " + Kernel32.INSTANCE.GetTickCount(); 123 | _eventLogAppender.append(asLogEvent(message, Level.INFO)); 124 | expectEvent(message, Level.INFO, EventLogType.Informational); 125 | } 126 | 127 | /** 128 | * Test case for {@link Win32EventLogAppender#append(LogEvent)} with warn 129 | * level. 130 | */ 131 | @Test 132 | public void testWarnEvent() { 133 | String message = "log4jna warn message @ " + Kernel32.INSTANCE.GetTickCount(); 134 | _eventLogAppender.append(asLogEvent(message, Level.WARN)); 135 | expectEvent(message, Level.WARN, EventLogType.Warning); 136 | } 137 | 138 | /** 139 | * Test case for {@link Win32EventLogAppender#append(LogEvent)} with fatal level. 140 | */ 141 | @Test 142 | public void testFatalEvent() { 143 | String message = "log4jna fatal message @ " + Kernel32.INSTANCE.GetTickCount(); 144 | _eventLogAppender.append(asLogEvent(message, Level.FATAL)); 145 | expectEvent(message, Level.FATAL, EventLogType.Error); 146 | } 147 | 148 | public void donttestRegistryValues() { 149 | String eventSourceKeyPath = "SYSTEM\\CurrentControlSet\\Services\\EventLog\\" 150 | + _eventLogAppender.getApplication() + "\\" + _eventLogAppender.getSource(); 151 | 152 | String eventMessageFileInRegistry = Advapi32Util.registryGetStringValue(WinReg.HKEY_LOCAL_MACHINE, 153 | eventSourceKeyPath, "EventMessageFile"); 154 | 155 | Path eventMessageFileGiven = Paths.get(_eventLogAppenderDLL); 156 | assertEquals(eventMessageFileInRegistry, eventMessageFileGiven.toString()); 157 | 158 | String categoryMessageFileInRegistry = Advapi32Util.registryGetStringValue(WinReg.HKEY_LOCAL_MACHINE, 159 | eventSourceKeyPath, "CategoryMessageFile"); 160 | 161 | Path categoryMessageFileGiven = Paths.get(_eventLogAppenderDLL); 162 | assertEquals(categoryMessageFileInRegistry, categoryMessageFileGiven.toString()); 163 | } 164 | 165 | private LogEvent asLogEvent(String message, Level level) { 166 | return new Log4jLogEvent.Builder().setLoggerName(TEST_LOGGER_NAME).setMarker(null) 167 | .setLoggerFqcn(_eventLogAppender.getClass().getName()).setLevel(level) 168 | .setMessage(new SimpleMessage(message)).setTimeMillis(System.currentTimeMillis()).build(); 169 | } 170 | 171 | /* 172 | * public void testException() { String message = 173 | * "log4jna exception message @ " + Kernel32.INSTANCE.GetTickCount(); 174 | * _logger.debug(message, new Exception("testing exception")); 175 | * expectEvent(message, Level.DEBUG, EventLogType.Informational); } 176 | */ 177 | 178 | private void expectEvent(String message, Level level, EventLogType eventLogType) { 179 | EventLogIterator iter = new EventLogIterator(null, TEST_LOGGER_NAME, WinNT.EVENTLOG_BACKWARDS_READ); 180 | try { 181 | assertTrue(iter.hasNext()); 182 | EventLogRecord record = iter.next(); 183 | assertEquals(TEST_LOGGER_NAME, record.getSource()); 184 | 185 | assertEquals(eventLogType, record.getType()); 186 | assertEquals(1, record.getRecord().NumStrings.intValue()); 187 | assertNull(record.getData()); 188 | 189 | // The full message includes a level and the full class name 190 | String fullMessage = level + " " + TEST_LOGGER_NAME + " - " + message; 191 | 192 | // The event message has the location tacked on the front 193 | StringBuilder eventMessage = new StringBuilder(); 194 | for (int i = 0; i < record.getStrings().length; i++) { 195 | eventMessage.append(record.getStrings()[i].trim()); 196 | } 197 | 198 | int levelMarker = eventMessage.indexOf(level.toString()); 199 | assertTrue("missing level marker in '" + eventMessage + "'", levelMarker >= 0); 200 | String eventMessageWithoutLocation = eventMessage.substring(levelMarker); 201 | 202 | assertEquals(fullMessage, eventMessageWithoutLocation); 203 | } finally { 204 | iter.close(); 205 | } 206 | } 207 | } 208 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. 10 | 11 | "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. 12 | 13 | "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. 14 | 15 | "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. 16 | 17 | "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. 18 | 19 | "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. 20 | 21 | "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). 22 | 23 | "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. 24 | 25 | "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." 26 | 27 | "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. 28 | 29 | 2. Grant of Copyright License. 30 | 31 | 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. 32 | 33 | 3. Grant of Patent License. 34 | 35 | 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. 36 | 37 | 4. Redistribution. 38 | 39 | 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: 40 | 41 | 1. You must give any other recipients of the Work or Derivative Works a copy of this License; and 42 | 43 | 2. You must cause any modified files to carry prominent notices stating that You changed the files; and 44 | 45 | 3. 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 46 | 47 | 4. 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. 48 | 49 | 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. 50 | 51 | 5. Submission of Contributions. 52 | 53 | 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. 54 | 55 | 6. Trademarks. 56 | 57 | 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. 58 | 59 | 7. Disclaimer of Warranty. 60 | 61 | 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. 62 | 63 | 8. Limitation of Liability. 64 | 65 | 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. 66 | 67 | 9. Accepting Warranty or Additional Liability. 68 | 69 | 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. -------------------------------------------------------------------------------- /log4jna-demo/src/test/java/org/dblock/log4jna/nt/demo/test/NewDemoTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache license, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with 4 | * the License. You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the license for the specific language governing permissions and 12 | * limitations under the license. 13 | */ 14 | package org.dblock.log4jna.nt.demo.test; 15 | 16 | import static org.junit.Assert.*; 17 | 18 | import org.apache.logging.log4j.Level; 19 | import org.dblock.log4jna.nt.demo.NewDemo; 20 | import org.junit.Before; 21 | import org.junit.Test; 22 | 23 | import com.sun.jna.platform.win32.WinNT; 24 | import com.sun.jna.platform.win32.Advapi32Util.EventLogIterator; 25 | import com.sun.jna.platform.win32.Advapi32Util.EventLogRecord; 26 | import com.sun.jna.platform.win32.Advapi32Util.EventLogType; 27 | 28 | /** 29 | * Test cases for {@link NewDemo} 30 | * 31 | * @author Claudio Trajtenberg 32 | * 33 | */ 34 | public class NewDemoTest { 35 | 36 | /* 37 | * Use this configuration if using the Application log4j2.xml file 38 | */ 39 | // private static final String EVENT_SOURCE = "Log4jnaTest"; 40 | 41 | /* 42 | * Use this configuration if using the Win32LogApplication log4j2.xml file 43 | */ 44 | private static final String EVENT_SOURCE = "WinLogger"; 45 | 46 | private static final String EXCEPTION = "java.lang.Exception: Pouporselly thrown for demo"; 47 | 48 | private NewDemo classUnderTest; 49 | 50 | private long testStartedTime; 51 | 52 | private long testEndedTime; 53 | 54 | @Before 55 | public void setUp() throws Exception { 56 | this.classUnderTest = new NewDemo(); 57 | } 58 | 59 | /** 60 | * Test case for {@link NewDemo#trace()}. 61 | */ 62 | @Test 63 | public void testTrace() { 64 | this.testStartedTime = System.currentTimeMillis() / 1000; 65 | this.classUnderTest.trace(); 66 | this.testEndedTime = System.currentTimeMillis() / 1000; 67 | expectEventNoException(Level.TRACE, EventLogType.Informational, 1); 68 | } 69 | 70 | /** 71 | * Test case for {@link NewDemo#debug()}. 72 | */ 73 | @Test 74 | public void testDebug() { 75 | this.testStartedTime = System.currentTimeMillis() / 1000; 76 | this.classUnderTest.debug(); 77 | this.testEndedTime = System.currentTimeMillis() / 1000; 78 | expectEventNoException(Level.DEBUG, EventLogType.Informational, 2); 79 | } 80 | 81 | /** 82 | * Test case for {@link NewDemo#info()}. 83 | */ 84 | @Test 85 | public void testInfo() { 86 | this.testStartedTime = System.currentTimeMillis() / 1000; 87 | this.classUnderTest.info(); 88 | this.testEndedTime = System.currentTimeMillis() / 1000; 89 | expectEventNoException(Level.INFO, EventLogType.Informational, 3); 90 | } 91 | 92 | /** 93 | * Test case for {@link NewDemo#warn()}. 94 | */ 95 | @Test 96 | public void testWarn() { 97 | this.testStartedTime = System.currentTimeMillis() / 1000; 98 | this.classUnderTest.warn(); 99 | this.testEndedTime = System.currentTimeMillis() / 1000; 100 | expectEventNoException(Level.WARN, EventLogType.Warning, 4); 101 | } 102 | 103 | /** 104 | * Test case for {@link NewDemo#error()}. 105 | */ 106 | @Test 107 | public void testError() { 108 | this.testStartedTime = System.currentTimeMillis() / 1000; 109 | this.classUnderTest.error(); 110 | this.testEndedTime = System.currentTimeMillis() / 1000; 111 | expectEventNoException(Level.ERROR, EventLogType.Error, 5); 112 | } 113 | 114 | /** 115 | * Test case for {@link NewDemo#fatal()}. 116 | */ 117 | @Test 118 | public void testFatal() { 119 | this.testStartedTime = System.currentTimeMillis() / 1000; 120 | this.classUnderTest.fatal(); 121 | this.testEndedTime = System.currentTimeMillis() / 1000; 122 | expectEventNoException(Level.FATAL, EventLogType.Error, 6); 123 | } 124 | 125 | /** 126 | * Test case for {@link NewDemo#warnWithException()}. 127 | */ 128 | @Test 129 | public void testWarnWithException() { 130 | this.testStartedTime = System.currentTimeMillis() / 1000; 131 | this.classUnderTest.warnWithException(); 132 | this.testEndedTime = System.currentTimeMillis() / 1000; 133 | expectEventException(Level.WARN, EventLogType.Warning, 4); 134 | } 135 | 136 | /** 137 | * Test case for {@link NewDemo#errorWithException()}. 138 | */ 139 | @Test 140 | public void testErrorWithException() { 141 | this.testStartedTime = System.currentTimeMillis() / 1000; 142 | this.classUnderTest.errorWithException(); 143 | this.testEndedTime = System.currentTimeMillis() / 1000; 144 | expectEventException(Level.ERROR, EventLogType.Error, 5); 145 | } 146 | 147 | /** 148 | * Test case for {@link NewDemo#fatalWithException()}. 149 | */ 150 | @Test 151 | public void testFatalWithException() { 152 | this.testStartedTime = System.currentTimeMillis() / 1000; 153 | this.classUnderTest.fatalWithException(); 154 | this.testEndedTime = System.currentTimeMillis() / 1000; 155 | expectEventException(Level.FATAL, EventLogType.Error, 6); 156 | } 157 | 158 | /** 159 | * @param level 160 | * @param eventLogType 161 | * @param eventLogCategory 162 | */ 163 | private void expectEventNoException(Level level, EventLogType eventLogType, int eventLogCategory) { 164 | EventLogIterator iter = new EventLogIterator(null, EVENT_SOURCE, WinNT.EVENTLOG_BACKWARDS_READ); 165 | try { 166 | assertTrue("No event log records to process", iter.hasNext()); 167 | int recordCount = 0; 168 | while (iter.hasNext() && recordCount < 2) { 169 | EventLogRecord record = iter.next(); 170 | 171 | if (record.getRecord().TimeWritten.longValue() >= this.testStartedTime 172 | && record.getRecord().TimeWritten.longValue() <= this.testEndedTime) { 173 | 174 | recordCount++; 175 | 176 | assertEquals(EVENT_SOURCE, record.getSource()); 177 | 178 | assertEquals(eventLogType, record.getType()); 179 | assertEquals(eventLogCategory, record.getRecord().EventCategory.intValue()); 180 | assertEquals(1, record.getRecord().NumStrings.intValue()); 181 | assertNull(record.getData()); 182 | 183 | // Build the message 184 | StringBuilder message = new StringBuilder(); 185 | switch (recordCount) { 186 | case 1: 187 | message.append("NewDemo: Exit "); 188 | break; 189 | 190 | case 2: 191 | message.append("NewDemo: Enter "); 192 | break; 193 | 194 | default: 195 | break; 196 | } 197 | message.append(level.name().toLowerCase()); 198 | String fullMessage = String.format("%-5s [main] %s", level, message); 199 | 200 | // The event message has the location tacked on the front 201 | StringBuilder eventMessage = new StringBuilder(); 202 | for (int i = 0; i < record.getStrings().length; i++) { 203 | eventMessage.append(record.getStrings()[i].trim()); 204 | } 205 | 206 | int levelMarker = eventMessage.indexOf(level.toString()); 207 | assertTrue("missing level marker in '" + eventMessage + "'", levelMarker >= 0); 208 | String eventMessageWithoutLocation = eventMessage.substring(levelMarker); 209 | 210 | assertEquals(fullMessage, eventMessageWithoutLocation); 211 | } 212 | } 213 | assertTrue("No records to process", recordCount > 0); 214 | } finally { 215 | iter.close(); 216 | } 217 | } 218 | 219 | /** 220 | * @param level 221 | * @param eventLogType 222 | * @param eventLogCategory 223 | */ 224 | private void expectEventException(Level level, EventLogType eventLogType, int eventLogCategory) { 225 | EventLogIterator iter = new EventLogIterator(null, EVENT_SOURCE, WinNT.EVENTLOG_BACKWARDS_READ); 226 | try { 227 | assertTrue(iter.hasNext()); 228 | EventLogRecord record = iter.next(); 229 | 230 | if (record.getRecord().TimeWritten.longValue() >= this.testStartedTime 231 | && record.getRecord().TimeWritten.longValue() <= this.testEndedTime) { 232 | 233 | assertEquals(EVENT_SOURCE, record.getSource()); 234 | 235 | assertEquals(eventLogType, record.getType()); 236 | assertEquals(eventLogCategory, record.getRecord().EventCategory.intValue()); 237 | assertEquals(1, record.getRecord().NumStrings.intValue()); 238 | assertNull(record.getData()); 239 | 240 | // Build the message 241 | String messageStart = String.format("%-5s [main] NewDemo: In %s with exception", level, 242 | level.name().toLowerCase()); 243 | 244 | // The event message has the location tacked on the front 245 | StringBuilder eventMessage = new StringBuilder(); 246 | for (int i = 0; i < record.getStrings().length; i++) { 247 | eventMessage.append(record.getStrings()[i].trim()); 248 | } 249 | 250 | int levelMarker = eventMessage.indexOf(level.toString()); 251 | assertTrue("missing level marker in '" + eventMessage + "'", levelMarker >= 0); 252 | String eventMessageWithoutLocation = eventMessage.substring(levelMarker); 253 | 254 | assertTrue(String.format("Mising %s", messageStart), 255 | eventMessageWithoutLocation.contains(messageStart)); 256 | assertTrue(String.format("Mising %s", EXCEPTION), eventMessageWithoutLocation.contains(EXCEPTION)); 257 | } 258 | } finally { 259 | iter.close(); 260 | } 261 | } 262 | } 263 | -------------------------------------------------------------------------------- /log4jna-demo/LICENSE.txt: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright 2010 Daniel Doubrovkine (dblock[at]dblock[dot]org) 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /src/site/markdown/USAGE.md: -------------------------------------------------------------------------------- 1 | # Log4JNA Configuration 2 | Log4JNA uses some configuration parameters to set up values in WindowsTM Registry that are required in order to write to the Event Viewer, all other Log4j 2TM values are used as described in the [Log4j 2TM Configuration Guide](http://logging.apache.org/log4j/2.x/manual/configuration.html) 3 | 4 | **Note:** WindowsTM requires Administrator privileges in order to write into the Registry, therefore you have to run the application as Administrator at least once, or [setup the registry manually](#registry) before using Log4JNA or whenever the location of the message file `Win32EventlogAppender.dll` changes in the configuration file. 5 | 6 | - [The message file `Win32EventlogAppender.dll`](#msg) 7 | - [Log4JNA Configuration Parameters](#cp) 8 | - [Log4JNA Registry Entries](#re) 9 | - [Log4J 2 configuration](#lj) 10 | - [Registry set up](#registry) 11 | - [Dependencies](#dep) 12 | 13 | ## The message file `Win32EventlogAppender.dll` 14 | WindowsTM Event Viewer and log depends on message files to find message content, formats, categories and types. 15 | 16 | Log4JNA uses a message file named `Win32EventlogAppender.dll`, we only define the categories and types and a generic message format that 17 | acts as pass through for the message format defined by your Log4j messages. 18 | 19 | Log4JNA needs to be able to find the file in order tof 20 | 21 | ## Log4JNA Configuration Parameters 22 | -------- 23 | 24 | | Name | Required | Default Value | Usage Description | 25 | | ----: | :--------: | :-------------: | ----- | 26 | | `name` | true | N/A | This required value **must always be `Win32EventLog`**.
It identifies the appender to Log4j 2TM Plugin management implementation | 27 | | `application` | false | Application | Indicates the top level location in the Event Viewer

The default is *Windows Logs -> Application* with a *Source* as per the `source` parameter.

If any other value than *Application* is used a Registry key in `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\` is created and Log4JNA will log into *Application and Service Logs -> <application-value>* with a Source column as per the `source` parameter. | 28 | | `source` | false | Log4jnaTest | Indicates the text to use in the *Source* column in the Event Viewer.
**We strongly recommend to use a different value** | 29 | | `eventMessageFile` | true | N/A | Indicates the file system location of the message file
The value can be relative as far as the program can determinate the absolute location in the file system. | 30 | | `categoryMessageFile` | true | N/A | Indicates the file system location of the message file
The value can be relative as far as the program can determinate the absolute location in the file system. | 31 | 32 | ## Log4JNA Registry Entries 33 | ------- 34 | 35 | All entries are created in **`HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\`**. 36 | 37 | The final location is defined by the `application` and `source` configuration parameters. 38 | 39 | | Entry name | Entry Type | Value | User Configurable | 40 | | ------------------- | ---------- | ---------------------------------------- | ----------------- | 41 | | TypesSupported | DWORD (32 bit) Value (REG_DWORD) | 0x7 | NO | 42 | | CategoryCount | DWORD (32 bit) Value (REG_DWORD) | 0x6 | NO | 43 | | EventMessageFile | String Value (REG_SZ) | <Full path to>\Win32EventlogAppender.dll | YES | 44 | | CategoryMessageFile | String Value (REG_SZ) | <Full path to>\Win32EventlogAppender.dll | YES | 45 | 46 | 47 | ## Log4J 2 configuration 48 | ------ 49 | 50 | Sample configuration files are provide in the Log4JNA Demo project and we use them for this examples. 51 | 52 | All Log4j 2TM configuration formats are supported, we show here *.xml* and *.properties* configuration examples, for *json*, *yaml*, and *strict xml* configuration follow the [Log4j 2TM documentation](http://logging.apache.org/log4j/2.x/manual/configuration.htm). 53 | 54 | ##### Configuring with all default values. 55 | `log4j2.xml` 56 | 57 | ```xml 58 | 59 | 60 | 61 | ... 62 | 63 | 64 | src\main\resources\Win32EventLogAppender.dll 65 | 66 | ... 67 | 68 | 69 | 70 | ... 71 | 72 | 73 | 74 | 75 | 76 | ... 77 | 78 | 79 | ``` 80 | 81 | `log4j2.properties` 82 | 83 | ```properties 84 | status=trace 85 | ... 86 | appender.winlogger.type = Win32EventLog 87 | appender.winlogger.name = Win32EventLog 88 | appender.winlogger.eventMessageFile=src\\main\\resources\\Win32EventLogAppender.dll 89 | appender.winlogger.categoryMessageFile=src\\main\\resources\\Win32EventLogAppender.dll 90 | appender.winlogger.layout.type = PatternLayout 91 | appender.winlogger.layout.pattern = %d{yyyy-MM-dd HH:mm:ss} %c{1} [%p] %m%n 92 | 93 | logger.winlogger.level = debug 94 | logger.winlogger.appenderRef.winlogger.ref = Win32EventLog 95 | 96 | ... 97 | ``` 98 | This configuration will result in the creation of Registry entries in `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\Application\Log4jnaTest` and writing to the Event Viewer `Windows Logs\Application` with a Source column value of `Log4jnaTest` 99 | 100 | ##### Configuring with default location and named Source. 101 | `log4j2.xml` 102 | 103 | ```xml 104 | 105 | 106 | 107 | ... 108 | 109 | 110 | src\main\resources\Win32EventLogAppender.dll 111 | 112 | ... 113 | 114 | 115 | 116 | ... 117 | 118 | 120 | 121 | 122 | 123 | ... 124 | 125 | 126 | ``` 127 | 128 | `log4j2.properties` 129 | 130 | ```properties 131 | status=trace 132 | ... 133 | appender.winlogger.type = Win32EventLog 134 | appender.winlogger.name = Win32EventLog 135 | appender.winlogger.source=WinLogger 136 | appender.winlogger.eventMessageFile=src\\main\\resources\\Win32EventLogAppender.dll 137 | appender.winlogger.categoryMessageFile=src\\main\\resources\\Win32EventLogAppender.dll 138 | appender.winlogger.layout.type = PatternLayout 139 | appender.winlogger.layout.pattern = %d{yyyy-MM-dd HH:mm:ss} %c{1} [%p] %m%n 140 | 141 | logger.winlogger.level = debug 142 | logger.winlogger.appenderRef.winlogger.ref = Win32EventLog 143 | 144 | ... 145 | ``` 146 | 147 | This configuration will result in the creation of Registry entries in `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\Application\WinLogger` and writing to the Event Viewer `Windows Logs\Application` with a Source column value of `WinLogger` 148 | 149 | ##### Configuring all values. 150 | `log4j2.xml` 151 | 152 | ```xml 153 | 154 | 155 | 156 | ... 157 | 158 | 159 | src\main\resources\Win32EventLogAppender.dll 160 | 161 | ... 162 | 163 | 164 | 165 | ... 166 | 167 | 169 | 170 | 171 | 172 | ... 173 | 174 | 175 | ``` 176 | 177 | `log4j2.properties` 178 | 179 | ```properties 180 | status=trace 181 | ... 182 | appender.winlogger.type = Win32EventLog 183 | appender.winlogger.name = Win32EventLog 184 | appender.winlogger.source=WinLogger 185 | appender.winlogger.application=Win32LogApplication 186 | appender.winlogger.eventMessageFile=src\\main\\resources\\Win32EventLogAppender.dll 187 | appender.winlogger.categoryMessageFile=src\\main\\resources\\Win32EventLogAppender.dll 188 | appender.winlogger.layout.type = PatternLayout 189 | appender.winlogger.layout.pattern = %d{yyyy-MM-dd HH:mm:ss} %c{1} [%p] %m%n 190 | 191 | logger.winlogger.level = debug 192 | logger.winlogger.appenderRef.winlogger.ref = Win32EventLog 193 | 194 | ... 195 | ``` 196 | 197 | This configuration will result in the creation of Registry entries in `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\Win32LogApplicationger\WinLogger` and writing to the Event Viewer `Applications and Service Logs\Win32LogApplication` with a Source column value of `WinLogger` 198 | 199 | ## Registry set up 200 | ------- 201 | 202 | #### All Defaults 203 | 1. Open `regedit` and browse to `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\Application\` 204 | 2. Right click and select `New Key`, name it `Log4jnaTest` 205 | 3. Add the following entries to `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\Application\Log4jnaTest` 206 | 207 | The registry should look like this: 208 | 209 | ![Registry Img](img/registry1.png) 210 | 211 | #### Espefiying the *Source* in the Default logger (Recommended) 212 | 1. Open `regedit` and browse to `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\Application\` 213 | 2. Right click and select `New Key`, give it a unique name that identifies your application. 214 | 3. Add the registry entries to `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\Application\Log4jnaTest` 215 | 216 | The registry should look like this: 217 | 218 | ![Registry Img](img/registry2.png) 219 | 220 | #### Using your own application entries in Event Viwer 221 | Here we use the Log4J Demo values as an example. 222 | 223 | 1. Open `regedit` and browse to `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\` 224 | 2. Right click and select `New Key`, name it `Win32LogApplication` 225 | 1. Add another key to `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\Win32LogApplication`, name it `WinLogger` 226 | 3. Add the registry entries to `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\Win32LogApplication\WinLogger` 227 | 228 | The registry should look like this: 229 | 230 | ![Registry Img](img/registry2.png) 231 | 232 | ## Dependencies 233 | ------- 234 | 235 | Log4JNA depends on `log4j-core`, `log4j-api`, `jna-plaform` and `jna`. 236 | 237 | Place the dependencies in a location visible in the CLASSPATH. 238 | 239 | Verify that the dependencies are not already provided by an Application Sever at the server class loader level. 240 | 241 | Place the JNA dependencies at the Application Server class loader level and declare JNA dependencies as provided in your build. 242 | 243 | The same principle can be applied for Log4JNA and log4j dependencies in an Application Server if several applications log to the Event Viewer. 244 | 245 | On Application Servers consider placing the message file `` 246 | 247 | Here is an example of Tomcat dependencies distribution on the file system for a single application. 248 | 249 | 250 | ``` 251 | Apche Tomcat 252 | |+ bin 253 | |+ conf 254 | |+ lib 255 | | |+ jna-core.jar 256 | | |+ jna.jar 257 | |+ logs 258 | |+ temp 259 | |+ webapps 260 | | |+ your-application 261 | | |+ WEBINF 262 | | |+ lib 263 | | |+ log4jna-api.jar 264 | | |+ lo4j-core.jar 265 | | |+ log4j-api.jar 266 | | |+ Win32EventlogAppender.dll 267 | |+ work 268 | ``` 269 | 270 | Here is an example of Tomcat dependencies distribution on the file system for multiple applications. 271 | 272 | ``` 273 | Apche Tomcat 274 | |+ bin 275 | |+ conf 276 | |+ lib 277 | | |+ jna-core.jar 278 | | |+ jna.jar 279 | | |+ log4jna-api.jar 280 | | |+ lo4j-core.jar 281 | | |+ log4j-api.jar 282 | | |+ Win32EventlogAppender.dll 283 | |+ logs 284 | |+ temp 285 | |+ webapps 286 | | |+ your-application 1 287 | | | |+ WEBINF 288 | | | |+ lib 289 | | | |+ other-dependencies.jar 290 | | |+ your-application 2 291 | | |+ WEBINF 292 | | |+ lib 293 | | |+ other-dependencies.jar 294 | |+ work 295 | ``` 296 | -------------------------------------------------------------------------------- /USAGE.md: -------------------------------------------------------------------------------- 1 | # Log4JNA Configuration 2 | 3 | Log4JNA uses some configuration parameters to set up values in WindowsTM Registry that are required in order to write to the Event Viewer, all other Log4j 2TM values are used as described in the [Log4j 2TM Configuration Guide](http://logging.apache.org/log4j/2.x/manual/configuration.html) 4 | 5 | **Note:** WindowsTM requires Administrator privileges in order to write into the Registry, therefore you have to run the application as Administrator at least once, or [setup the registry manually](#registry) before using Log4JNA or whenever the location of the message file `Win32EventlogAppender.dll` changes in the configuration file. 6 | 7 | - [The message file `Win32EventlogAppender.dll`](#msg) 8 | - [Log4JNA Configuration Parameters](#cp) 9 | - [Log4JNA Registry Entries](#re) 10 | - [Log4J 2 Configuration](#lj) 11 | - [Registry Set Up](#registry) 12 | - [Dependencies](#dep) 13 | 14 | ## The message file `Win32EventlogAppender.dll` 15 | 16 | WindowsTM Event Viewer and logging depends on message files to find message content, formats, categories and types. 17 | 18 | Log4JNA uses a message file named `Win32EventlogAppender.dll`, we only define the categories and a generic message format that acts as pass 19 | through for the message format defined by your Log4j messages. 20 | 21 | To format the messages properly Log4JNA and the native calls need to find the message file in the file system. 22 | 23 | Log4JNA locates the file using the `EventMessageFile` and `CategoryMessageFile` entries in the registry. 24 | 25 | If the entries in the registry do not exists, Log4JNA attempts to create them using the configuration values `eventMessageFile` and `categoryMessageFile`. 26 | 27 | ## Log4JNA Configuration Parameters 28 | 29 | | Name | Required | Default Value | Usage Description | 30 | | ----: | :--------: | :-------------: | ----- | 31 | | `name` | true | N/A | This required value **must always be `Win32EventLog`**.
It identifies the appender to Log4j 2TM Plugin management implementation | 32 | | `application` | false | Application | Indicates the top level location in the Event Viewer

The default is *Windows Logs -> Application* with a *Source* as per the `source` parameter.

If any other value than *Application* is used a Registry key in `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\` is created and Log4JNA will log into *Application and Service Logs -> <application-value>* with a Source column as per the `source` parameter. | 33 | | `source` | false | Log4jnaTest | Indicates the text to use in the *Source* column in the Event Viewer.
**We strongly recommend to use a different value** | 34 | | `eventMessageFile` | true | N/A | Indicates the file system location of the message file
The value can be relative as far as the program can determinate the absolute location in the file system. | 35 | | `categoryMessageFile` | true | N/A | Indicates the file system location of the message file
The value can be relative as far as the program can determinate the absolute location in the file system. | 36 | 37 | ## Log4JNA Registry Entries 38 | 39 | All entries are created in **`HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\`**. 40 | 41 | The final location is defined by the `application` and `source` configuration parameters. 42 | 43 | | Entry name | Entry Type | Value | User Configurable | 44 | | ------------------- | ---------- | ---------------------------------------- | ----------------- | 45 | | TypesSupported | DWORD (32 bit) Value (REG_DWORD) | 0x7 | NO | 46 | | CategoryCount | DWORD (32 bit) Value (REG_DWORD) | 0x6 | NO | 47 | | EventMessageFile | String Value (REG_SZ) | <Full path to>\Win32EventlogAppender.dll | YES | 48 | | CategoryMessageFile | String Value (REG_SZ) | <Full path to>\Win32EventlogAppender.dll | YES | 49 | 50 | 51 | ## Log4J 2 Configuration 52 | 53 | Sample configuration files are provided in the Log4JNA Demo project and we use them for this examples. 54 | 55 | All Log4j 2TM configuration formats are supported, we show here *.xml* and *.properties* configuration examples, for *json*, *yaml*, and *strict xml* configuration follow the [Log4j 2TM documentation](http://logging.apache.org/log4j/2.x/manual/configuration.htm). 56 | 57 | ##### Configuring with all default values 58 | 59 | `log4j2.xml` 60 | 61 | ```xml 62 | 63 | 64 | 65 | ... 66 | 67 | 68 | src\main\resources\Win32EventLogAppender.dll 69 | 70 | ... 71 | 72 | 73 | 74 | ... 75 | 76 | 77 | 78 | 79 | 80 | ... 81 | 82 | 83 | ``` 84 | 85 | `log4j2.properties` 86 | 87 | ```properties 88 | status=trace 89 | ... 90 | appender.winlogger.type = Win32EventLog 91 | appender.winlogger.name = Win32EventLog 92 | appender.winlogger.eventMessageFile=src\\main\\resources\\Win32EventLogAppender.dll 93 | appender.winlogger.categoryMessageFile=src\\main\\resources\\Win32EventLogAppender.dll 94 | appender.winlogger.layout.type = PatternLayout 95 | appender.winlogger.layout.pattern = %d{yyyy-MM-dd HH:mm:ss} %c{1} [%p] %m%n 96 | 97 | logger.winlogger.level = debug 98 | logger.winlogger.appenderRef.winlogger.ref = Win32EventLog 99 | 100 | ... 101 | ``` 102 | 103 | This configuration will result in the creation of Registry entries in `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\Application\Log4jnaTest` and writing to the Event Viewer `Windows Logs\Application` with a Source column value of `Log4jnaTest` 104 | 105 | ##### Configuring with default location and named Source 106 | 107 | `log4j2.xml` 108 | 109 | ```xml 110 | 111 | 112 | 113 | ... 114 | 115 | 116 | src\main\resources\Win32EventLogAppender.dll 117 | 118 | ... 119 | 120 | 121 | 122 | ... 123 | 124 | 126 | 127 | 128 | 129 | ... 130 | 131 | 132 | ``` 133 | 134 | `log4j2.properties` 135 | 136 | ```properties 137 | status=trace 138 | ... 139 | appender.winlogger.type = Win32EventLog 140 | appender.winlogger.name = Win32EventLog 141 | appender.winlogger.source=WinLogger 142 | appender.winlogger.eventMessageFile=src\\main\\resources\\Win32EventLogAppender.dll 143 | appender.winlogger.categoryMessageFile=src\\main\\resources\\Win32EventLogAppender.dll 144 | appender.winlogger.layout.type = PatternLayout 145 | appender.winlogger.layout.pattern = %d{yyyy-MM-dd HH:mm:ss} %c{1} [%p] %m%n 146 | 147 | logger.winlogger.level = debug 148 | logger.winlogger.appenderRef.winlogger.ref = Win32EventLog 149 | 150 | ... 151 | ``` 152 | 153 | This configuration will result in the creation of Registry entries in `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\Application\WinLogger` and writing to the Event Viewer `Windows Logs\Application` with a Source column value of `WinLogger` 154 | 155 | ##### Configuring all values 156 | 157 | `log4j2.xml` 158 | 159 | ```xml 160 | 161 | 162 | 163 | ... 164 | 165 | 166 | src\main\resources\Win32EventLogAppender.dll 167 | 168 | ... 169 | 170 | 171 | 172 | ... 173 | 174 | 176 | 177 | 178 | 179 | ... 180 | 181 | 182 | ``` 183 | 184 | `log4j2.properties` 185 | 186 | ```properties 187 | status=trace 188 | ... 189 | appender.winlogger.type = Win32EventLog 190 | appender.winlogger.name = Win32EventLog 191 | appender.winlogger.source=WinLogger 192 | appender.winlogger.application=Win32LogApplication 193 | appender.winlogger.eventMessageFile=src\\main\\resources\\Win32EventLogAppender.dll 194 | appender.winlogger.categoryMessageFile=src\\main\\resources\\Win32EventLogAppender.dll 195 | appender.winlogger.layout.type = PatternLayout 196 | appender.winlogger.layout.pattern = %d{yyyy-MM-dd HH:mm:ss} %c{1} [%p] %m%n 197 | 198 | logger.winlogger.level = debug 199 | logger.winlogger.appenderRef.winlogger.ref = Win32EventLog 200 | 201 | ... 202 | ``` 203 | 204 | This configuration will result in the creation of Registry entries in `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\Win32LogApplicationger\WinLogger` and writing to the Event Viewer `Applications and Service Logs\Win32LogApplication` with a Source column value of `WinLogger` 205 | 206 | ## Registry set up 207 | 208 | #### All Defaults 209 | 1. Open `regedit` and browse to `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\Application\` 210 | 2. Right click and select `New Key`, name it `Log4jnaTest` 211 | 3. Add the following entries to `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\Application\Log4jnaTest` 212 | 213 | The registry should look like this: 214 | 215 | ![Registry Img](src/site/resources/img/registry1.png) 216 | 217 | #### Specifying the *Source* in the Default logger (Recommended) 218 | 219 | 1. Open `regedit` and browse to `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\Application\` 220 | 2. Right click and select `New Key`, give it a unique name that identifies your application. 221 | 3. Add the registry entries to `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\Application\Log4jnaTest` 222 | 223 | The registry should look like this: 224 | 225 | ![Registry Img](src/site/resources/img/registry2.png) 226 | 227 | #### Using your own application entries in Event Viewer 228 | 229 | Here we use the Log4J Demo values as an example. 230 | 231 | 1. Open `regedit` and browse to `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\` 232 | 2. Right click and select `New Key`, name it `Win32LogApplication` 233 | 1. Add another key to `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\Win32LogApplication`, name it `WinLogger` 234 | 3. Add the registry entries to `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\Win32LogApplication\WinLogger` 235 | 236 | The registry should look like this: 237 | 238 | ![Registry Img](src/site/resources/img/registry2.png) 239 | 240 | ## Dependencies 241 | 242 | Log4JNA depends on `log4j-core`, `log4j-api`, `jna-plaform` and `jna`. 243 | 244 | Place the dependencies in a location visible in the CLASSPATH. 245 | 246 | Verify that the dependencies are not already provided by an Application Sever at the server class loader level. 247 | 248 | Place the JNA dependencies at the Application Server class loader level and declare JNA dependencies as provided in your build. 249 | 250 | The same principle can be applied for Log4JNA and log4j dependencies in an Application Server if several applications log to the Event Viewer. 251 | 252 | On Application Servers consider placing the message file `` 253 | 254 | Here is an example of Tomcat dependencies distribution on the file system for a single application. 255 | 256 | 257 | ``` 258 | Apache Tomcat 259 | |+ bin 260 | |+ conf 261 | |+ lib 262 | | |+ jna-core.jar 263 | | |+ jna.jar 264 | |+ logs 265 | |+ temp 266 | |+ webapps 267 | | |+ your-application 268 | | |+ WEBINF 269 | | |+ lib 270 | | |+ log4jna-api.jar 271 | | |+ lo4j-core.jar 272 | | |+ log4j-api.jar 273 | | |+ Win32EventlogAppender.dll 274 | |+ work 275 | ``` 276 | 277 | Here is an example of Tomcat dependencies distribution on the file system for multiple applications. 278 | 279 | ``` 280 | Apache Tomcat 281 | |+ bin 282 | |+ conf 283 | |+ lib 284 | | |+ jna-core.jar 285 | | |+ jna.jar 286 | | |+ log4jna-api.jar 287 | | |+ lo4j-core.jar 288 | | |+ log4j-api.jar 289 | | |+ Win32EventlogAppender.dll 290 | |+ logs 291 | |+ temp 292 | |+ webapps 293 | | |+ your-application 1 294 | | | |+ WEBINF 295 | | | |+ lib 296 | | | |+ other-dependencies.jar 297 | | |+ your-application 2 298 | | |+ WEBINF 299 | | |+ lib 300 | | |+ other-dependencies.jar 301 | |+ work 302 | ``` 303 | 304 | -------------------------------------------------------------------------------- /log4jna-api/src/main/java/org/dblock/log4jna/nt/Win32EventLogAppender.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 3 | * use this file except in compliance with the License. You may obtain a copy 4 | * of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | package org.dblock.log4jna.nt; 16 | 17 | import java.io.Serializable; 18 | import java.nio.file.Files; 19 | import java.nio.file.Path; 20 | import java.nio.file.Paths; 21 | 22 | import org.apache.logging.log4j.Level; 23 | import org.apache.logging.log4j.core.Filter; 24 | import org.apache.logging.log4j.core.Layout; 25 | import org.apache.logging.log4j.core.LogEvent; 26 | import org.apache.logging.log4j.core.appender.AbstractAppender; 27 | import org.apache.logging.log4j.core.config.plugins.Plugin; 28 | import org.apache.logging.log4j.core.config.plugins.PluginAttribute; 29 | import org.apache.logging.log4j.core.config.plugins.PluginElement; 30 | import org.apache.logging.log4j.core.config.plugins.PluginFactory; 31 | import org.apache.logging.log4j.spi.StandardLevel; 32 | 33 | import com.sun.jna.platform.win32.Advapi32; 34 | import com.sun.jna.platform.win32.Advapi32Util; 35 | import com.sun.jna.platform.win32.Kernel32; 36 | import com.sun.jna.platform.win32.Win32Exception; 37 | import com.sun.jna.platform.win32.WinNT; 38 | import com.sun.jna.platform.win32.WinNT.HANDLE; 39 | import com.sun.jna.platform.win32.WinReg; 40 | 41 | /** 42 | * Append to the NT event log system. 43 | * 44 | *

45 | * WARNING This appender can only be installed and used on a Windows 46 | * system. 47 | * 48 | *

49 | * Do not forget to place jna.jar and platform.jar in the CLASSPATH. 50 | *

51 | * 52 | * @author Chris Taylor 53 | * @author Jim Cakalic 54 | * @author Daniel Doubrovkine 55 | * @author Tony Niemira 56 | * @author Claudio Trajtenberg 57 | * @author yokra 58 | */ 59 | @Plugin(name = "Win32EventLog", category = "Core", elementType = "appender", printObject = true) 60 | public class Win32EventLogAppender extends AbstractAppender { 61 | 62 | private static final String EVENT_LOG_PATH = "SYSTEM\\CurrentControlSet\\Services\\EventLog\\"; 63 | private static final String CATEGORY_MESSAGE_FILE = "CategoryMessageFile"; 64 | private static final String EVENT_MESSAGE_FILE = "EventMessageFile"; 65 | private static final int CATEGORY_COUNT = 6; 66 | private static final int TYPES_SUPPORTED = 7; 67 | private static final String DEFAULT_SOURCE = "Log4jna"; 68 | private static final String DEFAULT_APPLICATION = "Application"; 69 | /** 70 | * 71 | */ 72 | private String _source = null; 73 | private String _server = null; 74 | private String _application = DEFAULT_APPLICATION; 75 | private String _eventMessageFile = ""; 76 | private String _categoryMessageFile = ""; 77 | 78 | private HANDLE _handle = null; 79 | 80 | /** 81 | * @param name The appender name Win32EventLog 82 | * @param server The server for remote logging 83 | * @param source The Event View Source 84 | * @param application The Event View application (location) 85 | * @param eventMessageFile The message file location in the file system 86 | * @param categoryMessageFile The message file location in the file system 87 | * @param layout A Log4j Layout 88 | * @param filter A Log4j Filter 89 | * @return 90 | */ 91 | @PluginFactory 92 | public static Win32EventLogAppender createAppender(@PluginAttribute("name") String name, 93 | @PluginAttribute("server") String server, @PluginAttribute("source") String source, 94 | @PluginAttribute("application") String application, 95 | @PluginAttribute("eventMessageFile") String eventMessageFile, 96 | @PluginAttribute("categoryMessageFile") String categoryMessageFile, 97 | @PluginElement("Layout") Layout layout, @PluginElement("Filters") Filter filter) { 98 | return new Win32EventLogAppender(name, server, source, application, eventMessageFile, categoryMessageFile, 99 | layout, filter); 100 | } 101 | 102 | /** 103 | * @param name The appender name Win32EventLog 104 | * @param server The server for remote logging 105 | * @param source The Event View Source 106 | * @param application The Event View application (location) 107 | * @param eventMessageFile The message file location in the file system 108 | * @param categoryMessageFile The message file location in the file system 109 | * @param layout A Log4j Layout 110 | * @param filter A Log4j Filter 111 | */ 112 | public Win32EventLogAppender(String name, String server, String source, String application, String eventMessageFile, 113 | String categoryMessageFile, Layout layout, Filter filter) { 114 | super(name, filter, layout); 115 | if (source == null || source.length() == 0) { 116 | source = DEFAULT_SOURCE; 117 | } 118 | 119 | if (eventMessageFile != null) { 120 | Path p = Paths.get(eventMessageFile); 121 | if (Files.exists(p)) { 122 | setEventMessageFile(p.toAbsolutePath().toString()); 123 | } 124 | } 125 | 126 | if (categoryMessageFile != null) { 127 | Path p = Paths.get(categoryMessageFile); 128 | if (Files.exists(p)) { 129 | setCategoryMessageFile(p.toAbsolutePath().toString()); 130 | } 131 | } 132 | 133 | this._server = server; 134 | setSource(source); 135 | setApplication(application); 136 | } 137 | 138 | /** 139 | * The Source option which names the source of the event. The current 140 | * value of this constant is Source. 141 | */ 142 | public void setSource(String source) { 143 | 144 | if (source == null || source.length() == 0) { 145 | source = DEFAULT_SOURCE; 146 | } 147 | 148 | _source = source.trim(); 149 | } 150 | 151 | /** 152 | * @return 153 | */ 154 | public String getSource() { 155 | return _source; 156 | } 157 | 158 | /** 159 | * The Application option which names the subsection of the 160 | * 'Applications and Services Log'. The default value of this constant is 161 | * Application. 162 | * 163 | * @param application The Event View application (location) 164 | */ 165 | public void setApplication(String application) { 166 | 167 | if (application == null || application.length() == 0) { 168 | application = DEFAULT_APPLICATION; 169 | } 170 | 171 | _application = application.trim(); 172 | } 173 | 174 | /** 175 | * @return 176 | */ 177 | public String getApplication() { 178 | return _application; 179 | } 180 | 181 | /** 182 | * 183 | */ 184 | public void close() { 185 | if (_handle != null) { 186 | if (!Advapi32.INSTANCE.DeregisterEventSource(_handle)) { 187 | throw new Win32Exception(Kernel32.INSTANCE.GetLastError()); 188 | } 189 | _handle = null; 190 | } 191 | } 192 | 193 | /** 194 | * The EventMessageFile option which sets file location of the Event 195 | * Messages 196 | * 197 | * @param eventMessageFile The message file location in the file system 198 | */ 199 | public void setEventMessageFile(String eventMessageFile) { 200 | _eventMessageFile = eventMessageFile.trim(); 201 | } 202 | 203 | /** 204 | * @return 205 | */ 206 | public String getEventMessageFile() { 207 | return _eventMessageFile; 208 | } 209 | 210 | /** 211 | * The CategoryMessageFile option which sets file location of the 212 | * Catagory Messages 213 | * 214 | * @param categoryMessageFile The message file location in the file system 215 | */ 216 | public void setCategoryMessageFile(String categoryMessageFile) { 217 | _categoryMessageFile = categoryMessageFile.trim(); 218 | } 219 | 220 | /** 221 | * @return 222 | */ 223 | public String getCategoryMessageFile() { 224 | return _categoryMessageFile; 225 | } 226 | 227 | /** 228 | * 229 | */ 230 | private void registerEventSource() { 231 | close(); 232 | 233 | try { 234 | _handle = registerEventSource(_server, _source, _application, _eventMessageFile, _categoryMessageFile); 235 | } catch (Exception e) { 236 | close(); 237 | throw new RuntimeException("Could not register event source.", e); 238 | } 239 | } 240 | 241 | /** 242 | * 243 | */ 244 | public void activateOptions() { 245 | registerEventSource(); 246 | } 247 | 248 | 249 | /** 250 | * {@inheritDoc} 251 | */ 252 | public void append(LogEvent event) { 253 | 254 | if (_handle == null) { 255 | registerEventSource(); 256 | } 257 | 258 | String s = new String(getLayout().toByteArray(event)); 259 | final int messageID = 0x1000; 260 | 261 | String[] buffer = { s }; 262 | 263 | if (Advapi32.INSTANCE.ReportEvent(_handle, getEventLogType(event.getLevel()), 264 | getEventLogCategory(event.getLevel()), messageID, null, buffer.length, 0, buffer, null) == false) { 265 | Exception e = new Win32Exception(Kernel32.INSTANCE.GetLastError()); 266 | getHandler().error("Failed to report event [" + s + "].", event, e); 267 | } 268 | } 269 | 270 | /** 271 | * {@inheritDoc} 272 | */ 273 | public void finalize() { 274 | close(); 275 | } 276 | 277 | /** 278 | * The Win32EventLogAppender requires a layout. Hence, this 279 | * method always returns true. 280 | */ 281 | public boolean requiresLayout() { 282 | return true; 283 | } 284 | 285 | /** 286 | * @param server The server for remote logging 287 | * @param source The Event View Source 288 | * @param application The Event View application (location) 289 | * @param eventMessageFile The message file location in the file system 290 | * @param categoryMessageFile The message file location in the file system 291 | * @return 292 | */ 293 | private HANDLE registerEventSource(String server, String source, String application, String eventMessageFile, 294 | String categoryMessageFile) { 295 | String applicationKeyPath = EVENT_LOG_PATH + application; 296 | String eventSourceKeyPath = applicationKeyPath + "\\" + source; 297 | if (Advapi32Util.registryKeyExists(WinReg.HKEY_LOCAL_MACHINE, applicationKeyPath)) { 298 | if (Advapi32Util.registryKeyExists(WinReg.HKEY_LOCAL_MACHINE, eventSourceKeyPath)) { 299 | setVariableKeys(eventMessageFile, categoryMessageFile, eventSourceKeyPath); 300 | } else { 301 | createAndSetAllKeys(eventMessageFile, categoryMessageFile, eventSourceKeyPath); 302 | } 303 | } else { 304 | createAndSetAllKeys(eventMessageFile, categoryMessageFile, eventSourceKeyPath); 305 | } 306 | 307 | HANDLE h = Advapi32.INSTANCE.RegisterEventSource(server, source); 308 | if (h == null) { 309 | throw new Win32Exception(Kernel32.INSTANCE.GetLastError()); 310 | } 311 | 312 | return h; 313 | } 314 | 315 | /** 316 | * 317 | * @param eventMessageFile The message file location in the file system 318 | * @param categoryMessageFile The message file location in the file system 319 | * @param eventSourceKeyPath The registry path 320 | */ 321 | private void createAndSetAllKeys(String eventMessageFile, String categoryMessageFile, String eventSourceKeyPath) { 322 | if (Advapi32Util.registryCreateKey(WinReg.HKEY_LOCAL_MACHINE, eventSourceKeyPath)) { 323 | Advapi32Util.registrySetIntValue(WinReg.HKEY_LOCAL_MACHINE, eventSourceKeyPath, "TypesSupported", 324 | TYPES_SUPPORTED); 325 | Advapi32Util.registrySetIntValue(WinReg.HKEY_LOCAL_MACHINE, eventSourceKeyPath, "CategoryCount", 326 | CATEGORY_COUNT); 327 | setVariableKeys(eventMessageFile, categoryMessageFile, eventSourceKeyPath); 328 | } 329 | } 330 | 331 | /** 332 | * Set the file location only if it does not exist or has changed. 333 | * 334 | * @param eventMessageFile The message file location in the file system 335 | * @param categoryMessageFile The message file location in the file system 336 | * @param eventSourceKeyPath The registry path 337 | */ 338 | private void setVariableKeys(String eventMessageFile, String categoryMessageFile, String eventSourceKeyPath) { 339 | if (!Advapi32Util.registryValueExists(WinReg.HKEY_LOCAL_MACHINE, eventSourceKeyPath, EVENT_MESSAGE_FILE) 340 | || !Advapi32Util 341 | .registryGetStringValue(WinReg.HKEY_LOCAL_MACHINE, eventSourceKeyPath, EVENT_MESSAGE_FILE) 342 | .equalsIgnoreCase(eventMessageFile)) { 343 | Advapi32Util.registrySetStringValue(WinReg.HKEY_LOCAL_MACHINE, eventSourceKeyPath, EVENT_MESSAGE_FILE, 344 | eventMessageFile); 345 | } 346 | if (!Advapi32Util.registryValueExists(WinReg.HKEY_LOCAL_MACHINE, eventSourceKeyPath, CATEGORY_MESSAGE_FILE) 347 | || !Advapi32Util 348 | .registryGetStringValue(WinReg.HKEY_LOCAL_MACHINE, eventSourceKeyPath, CATEGORY_MESSAGE_FILE) 349 | .equalsIgnoreCase(categoryMessageFile)) { 350 | Advapi32Util.registrySetStringValue(WinReg.HKEY_LOCAL_MACHINE, eventSourceKeyPath, CATEGORY_MESSAGE_FILE, 351 | categoryMessageFile); 352 | } 353 | } 354 | 355 | /** 356 | * Convert log4j Priority to an EventLog type. The log4j package supports 8 357 | * defined priorities, but the NT EventLog only knows 3 event types of 358 | * interest to us: ERROR, WARNING, and INFO. 359 | * 360 | * @param level 361 | * Log4j priority. 362 | * @return EventLog type. 363 | */ 364 | private static int getEventLogType(Level level) { 365 | StandardLevel standardLevel = StandardLevel.getStandardLevel(level.intLevel()); 366 | switch (standardLevel) { 367 | case FATAL: 368 | case ERROR: { 369 | return WinNT.EVENTLOG_ERROR_TYPE; 370 | } 371 | case WARN: { 372 | return WinNT.EVENTLOG_WARNING_TYPE; 373 | } 374 | default: { 375 | return WinNT.EVENTLOG_INFORMATION_TYPE; 376 | } 377 | } 378 | } 379 | 380 | /** 381 | * Convert log4j Priority to an EventLog category. Each category is backed 382 | * by a message resource so that proper category names will be displayed in 383 | * the NT Event Viewer. 384 | * 385 | * @param level Log4J priority. 386 | * @return EventLog category. 387 | */ 388 | private static int getEventLogCategory(Level level) { 389 | StandardLevel standardLevel = StandardLevel.getStandardLevel(level.intLevel()); 390 | switch (standardLevel) { 391 | case FATAL: { 392 | return 6; 393 | } 394 | case ERROR: { 395 | return 5; 396 | } 397 | case WARN: { 398 | return 4; 399 | } 400 | case INFO: { 401 | return 3; 402 | } 403 | case DEBUG: { 404 | return 2; 405 | } 406 | default: { 407 | return 1; 408 | } 409 | } 410 | } 411 | 412 | } 413 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | org.dblock.log4jna 4 | log4jna 5 | 2.1.1-SNAPSHOT 6 | pom 7 | Log4JNA Parent 8 | https://github.com/dblock/log4jna 9 | Log4jna is a library of native appenders for log4j. Unlike the native implementation(s) in Log4j, this project uses JNA and therefore does not require a native DLL in a system directory or on PATH. 10 | 11 | 12 | The Apache Software License, Version 2.0 13 | http://www.apache.org/licenses/LICENSE-2.0.txt 14 | repo 15 | 16 | 17 | 18 | https://github.com/dblock/log4jna/issues 19 | github 20 | 21 | 22 | scm:git:https://github.com/dblock/log4jna.git 23 | scm:git:https://github.com/dblock/log4jna.git 24 | https://github.com/dblock/log4jna.git 25 | HEAD 26 | 27 | 28 | GitHub Actions 29 | https://github.com/dblock/log4jna/actions 30 | 31 | 32 | 33 | dblock 34 | Daniel Doubrovkine 35 | dblock@dblock.org 36 | america/new_york 37 | 38 | https://avatars2.githubusercontent.com/u/542335?s=50 39 | 40 | 41 | 42 | cstaylor 43 | Chris Taylor 44 | cstaylor@pacbell.net 45 | 46 | 47 | jim_cakalic 48 | Jim Cakalic 49 | jim_cakalic@na.biomerieux.com 50 | 51 | 52 | tony 53 | Tony Niemira 54 | tony@niemira.com 55 | 56 | 57 | claudiow 58 | Claudio Trajtenberg 59 | claudio.trajtenberg@cgtca.ca 60 | america/winnipeg 61 | 62 | https://avatars2.githubusercontent.com/u/7267903?s=50 63 | 64 | 65 | 66 | yokra9 67 | yokra 68 | yokra9@outlook.com 69 | asia/tokyo 70 | 71 | https://avatars2.githubusercontent.com/u/53964890?s=50 72 | 73 | 74 | 75 | 76 | 77 | 78 | org.apache.logging.log4j 79 | log4j-core 80 | ${log4j.version} 81 | 82 | 83 | net.java.dev.jna 84 | jna-platform 85 | ${jna.version} 86 | 87 | 88 | junit 89 | junit 90 | ${junit.version} 91 | test 92 | 93 | 94 | 95 | 96 | 97 | junit 98 | junit 99 | test 100 | 101 | 102 | 103 | 104 | 105 | org.apache.maven.wagon 106 | wagon-ssh 107 | 3.5.3 108 | 109 | 110 | 111 | 112 | 113 | 114 | org.apache.maven.plugins 115 | maven-compiler-plugin 116 | ${mavencompilerplugin.version} 117 | 118 | ${java.version} 119 | ${java.version} 120 | 121 | 122 | 123 | org.apache.maven.plugins 124 | maven-clean-plugin 125 | 3.3.2 126 | 127 | 128 | org.apache.maven.plugins 129 | maven-javadoc-plugin 130 | ${mavenjavadocplugin.version} 131 | 132 | 133 | org.apache.maven.plugins 134 | maven-jar-plugin 135 | 3.4.2 136 | 137 | 138 | org.apache.maven.plugins 139 | maven-source-plugin 140 | 3.3.1 141 | 142 | 143 | 144 | org.apache.maven.plugins 145 | maven-assembly-plugin 146 | 3.7.1 147 | 148 | 149 | 150 | org.apache.maven.plugins 151 | maven-install-plugin 152 | 3.1.2 153 | 154 | 155 | org.apache.maven.plugins 156 | maven-release-plugin 157 | 3.0.1 158 | 159 | 160 | org.apache.maven.plugins 161 | maven-deploy-plugin 162 | 3.1.2 163 | 164 | 165 | org.apache.maven.plugins 166 | maven-scm-publish-plugin 167 | 3.2.1 168 | 169 | 170 | org.apache.maven.plugins 171 | maven-gpg-plugin 172 | 3.2.4 173 | 174 | 175 | 176 | 177 | 178 | org.apache.maven.plugins 179 | maven-site-plugin 180 | 3.12.1 181 | 182 | true 183 | 184 | 185 | 186 | org.apache.maven.doxia 187 | doxia-module-markdown 188 | 1.12.0 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | org.apache.maven.plugins 198 | maven-javadoc-plugin 199 | 200 | 201 | 202 | jar 203 | 204 | 205 | 206 | 207 | 208 | org.apache.maven.plugins 209 | maven-source-plugin 210 | 211 | 212 | 213 | jar 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | maven-site-plugin 222 | 223 | 224 | prepare-package 225 | 226 | site 227 | stage 228 | 229 | 230 | 231 | 232 | 233 | org.apache.maven.plugins 234 | maven-release-plugin 235 | 236 | release 237 | deploy 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | site 246 | 247 | 248 | 249 | 250 | org.apache.maven.plugins 251 | maven-scm-publish-plugin 252 | 3.2.1 253 | false 254 | 255 | github.com 256 | gh-pages 257 | scm:git:https://github.com/dblock/log4jna.git 258 | ${env.GITHUB_USERNAME} 259 | ${env.GITHUB_TOKEN} 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | deploy 268 | 269 | 270 | 271 | org.apache.maven.plugins 272 | maven-gpg-plugin 273 | 274 | 275 | sign-artifacts 276 | verify 277 | 278 | sign 279 | 280 | 281 | 282 | 283 | 284 | --pinentry-mode 285 | loopback 286 | 287 | 288 | 289 | 290 | org.sonatype.central 291 | central-publishing-maven-plugin 292 | 0.5.0 293 | true 294 | 295 | central 296 | true 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | release 305 | 306 | 307 | 308 | org.apache.maven.plugins 309 | maven-gpg-plugin 310 | 311 | 312 | sign-artifacts 313 | verify 314 | 315 | sign 316 | 317 | 318 | 319 | 320 | 321 | --pinentry-mode 322 | loopback 323 | 324 | 325 | 326 | 327 | org.sonatype.central 328 | central-publishing-maven-plugin 329 | 0.5.0 330 | true 331 | 332 | central 333 | true 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | org.apache.maven.plugins 344 | maven-project-info-reports-plugin 345 | 3.5.0 346 | 347 | 348 | org.apache.maven.plugins 349 | maven-site-plugin 350 | 3.12.1 351 | 352 | 353 | org.apache.maven.plugins 354 | maven-javadoc-plugin 355 | 3.6.3 356 | false 357 | 358 | private 359 | 360 | https://logging.apache.org/log4j/2.x/javadoc/log4j-core/ 361 | https://logging.apache.org/log4j/2.x/javadoc/log4j-api/ 362 | https://docs.oracle.com/javase/8/docs/api/ 363 | https://java-native-access.github.io/jna/5.13.0/javadoc/ 364 | 365 | 366 | 367 | 368 | aggregate 369 | false 370 | 371 | private 372 | 373 | https://logging.apache.org/log4j/2.x/javadoc/log4j-core/ 374 | https://logging.apache.org/log4j/2.x/javadoc/log4j-api/ 375 | https://docs.oracle.com/javase/8/docs/api/ 376 | https://java-native-access.github.io/jna/5.13.0/javadoc/ 377 | 378 | 379 | 380 | aggregate 381 | test-aggregate 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 2.23.1 390 | 5.14.0 391 | 4.13.2 392 | 1.8 393 | 1.8 394 | 3.12.1 395 | 3.7.0 396 | UTF-8 397 | UTF-8 398 | UTF-8 399 | 400 | 401 | 402 | central 403 | https://oss.sonatype.org/service/local/staging/deploy/maven2 404 | 405 | 406 | central 407 | https://oss.sonatype.org/content/repositories/snapshots 408 | 409 | 410 | sites 411 | Log4JNA Site 412 | http://dblock.github.io/log4jna/ 413 | 414 | 415 | 416 | log4jna-win32dll 417 | log4jna-api 418 | log4jna-demo 419 | log4jna-assembly 420 | 421 | 422 | The Log4JNA Team 423 | https://github.com/dblock/log4jna 424 | 425 | 426 | --------------------------------------------------------------------------------