log4j2-sftp-appender

SFTP appender for log4j2

License

License

GroupId

GroupId

io.github.c-a-services
ArtifactId

ArtifactId

log4j2-sftp-appender
Last Version

Last Version

2018.11.7
Release Date

Release Date

Type

Type

jar
Description

Description

log4j2-sftp-appender
SFTP appender for log4j2
Project URL

Project URL

https://github.com/c-a-services/log4j2-sftp-appender
Source Code Management

Source Code Management

https://github.com/c-a-services/log4j2-sftp-appender

Download log4j2-sftp-appender

How to add to project

<!-- https://jarcasting.com/artifacts/io.github.c-a-services/log4j2-sftp-appender/ -->
<dependency>
    <groupId>io.github.c-a-services</groupId>
    <artifactId>log4j2-sftp-appender</artifactId>
    <version>2018.11.7</version>
</dependency>
// https://jarcasting.com/artifacts/io.github.c-a-services/log4j2-sftp-appender/
implementation 'io.github.c-a-services:log4j2-sftp-appender:2018.11.7'
// https://jarcasting.com/artifacts/io.github.c-a-services/log4j2-sftp-appender/
implementation ("io.github.c-a-services:log4j2-sftp-appender:2018.11.7")
'io.github.c-a-services:log4j2-sftp-appender:jar:2018.11.7'
<dependency org="io.github.c-a-services" name="log4j2-sftp-appender" rev="2018.11.7">
  <artifact name="log4j2-sftp-appender" type="jar" />
</dependency>
@Grapes(
@Grab(group='io.github.c-a-services', module='log4j2-sftp-appender', version='2018.11.7')
)
libraryDependencies += "io.github.c-a-services" % "log4j2-sftp-appender" % "2018.11.7"
[io.github.c-a-services/log4j2-sftp-appender "2018.11.7"]

Dependencies

provided (2)

Group / Artifact Type Version
org.apache.logging.log4j : log4j-core jar 2.11.1
com.hierynomus : sshj jar 0.26.0

test (1)

Group / Artifact Type Version
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.

log4j2-sftp-appender

Append the log-output from log4j2.xml to sftp server

Configuration

log4j2.xml file:

Add the import to the root element:

<Configuration status="warn" packages="io.github.c_a_services.log4j2">

Add the appender:

	<Appenders>
		<DailyFileSftpAppender
			name="sftpAppender"
			filePattern="${date:HHmmssSSS}-mule.log"
			hostName="ftp.yourdnsservername.com"
			pathName="/${sys:stage.name:-nostage}/"
			userName="ftpUserName"
			publicKeyResource="secret/ftpUserName.pub"
			privateKeyResource="secret/ftpUserName"
			passPhrase="yourPassPhrase">
			<PatternLayout pattern="%d %-5p %c{1} - %m [%t]%n" />
         <DefaultRolloverStrategy max="10"/>
		</DailyFileSftpAppender>
	</Appenders>
  • name: will needs to be referenced via <AppenderRef ref="sftpAppender" /> later in the file
  • filepatter: suffix of the files (date will be placed in the beginning always)
  • hostName: ftp hostname
  • pathName: path on that host (here prefixing with system property stage.name)
  • userName: userName to connect with
  • publicKeyResource: resource in your classpath (can be generated via ssh-keygen -f ftpUserName -t rsa -b 4092 -N yourPassPhrase)
  • privateKeyResource: resource in your classpath
  • PatternLayout: Any patternlayout
  • DefaultRolloverStrategy: Days to keep logfiles.

for above example the resourepath looks like: /your-mule-application/src/main/resources/secret/ftpUserName /your-mule-application/src/main/resources/secret/ftpUserName.pub

Further details, see log4j2-configuration

Dependencies

Dependencies are marked provided and so either needs to be available in your server or added manually:

this:
	<dependency>
		<groupId>io.github.c-a-services</groupId>
		<artifactId>log4j2-sftp-appender</artifactId>
		<version>2018.11.1</version>
	</dependency>

(for newest Version see pom.xml or maven central)

log4j2:
		<dependency>
			<groupId>org.apache.logging.log4j</groupId>
			<artifactId>log4j-core</artifactId>
			<version>2.11.1</version>
		</dependency>

(for newest Version see log4j2-maven-artifacts)

sshj:
		<dependency>
			<groupId>com.hierynomus</groupId>
			<artifactId>sshj</artifactId>
			<version>0.26.0</version>
		</dependency>

(for newest Version see sshj)



For changing this file see Markdown-Cheatsheet

io.github.c-a-services

C&A Services GmbH & Co. OHG

Versions

Version
2018.11.7