A log4j appender which forwards logs straight to Azure EventHub as events. Currently uses the REST API provided by Microsoft here to asynchronously forward events.
Currently the only method available is to compile from source:
-
Clone this project, and install
maven
-
Compile the project into a single jar using
maven
:
mvn clean compile assembly:single
- You should now have a
jar
you can use in your project:
log4j-eventhub-appender-X.X-SNAPSHOT-jar-with-dependencies.jar
Assuming you have set up your EventHub destination along with SAS (Shared Access Keys) for authentication, you can configure log4j as follows:
- Create a
config.properties
file in your project classpath with the properties shown below:
Parameter | Required | Default | Description |
---|---|---|---|
namespacename | Yes | Azure EventHub Namespace Name | |
eventhubname | Yes | Azure EventHub Name | |
saskeyname | Yes | Azure EventHub Shared Access Key Name which has been granted permission to read/write to the specified EventHub | |
retries | No | 0 | Number of times to retry send (HTTP Post) requests on failure (Any response other than 2xx) |
An example is shown below:
namespacename=my-eventhub-namespace
eventhubname=my-eventhub-name
saskeyname=my-sas-key-name
saskey=my-sas-key
retries=0
-
Ensure that the
jar
built in the installation step is present in your dependencies -
Configure your
log4j.properties
file to use the appender:
# base logger
log4j.rootCategory=INFO,eventhub
log4j.appender.eventhub=com.rahoogan.log4j.EventHubRestAppender
log4j.appender.eventhub.layout.ConversionPattern=%m%n
Licensed under the MIT License