Cxf Client Logger

Cxf Client Logger Project

License

License

GroupId

GroupId

com.bilalalp
ArtifactId

ArtifactId

cxflogger
Last Version

Last Version

1.0
Release Date

Release Date

Type

Type

jar
Description

Description

Cxf Client Logger
Cxf Client Logger Project
Project URL

Project URL

https://github.com/lalib/cxfclientlogger/
Source Code Management

Source Code Management

https://github.com/lalib/cxfclientlogger.git

Download cxflogger

How to add to project

<!-- https://jarcasting.com/artifacts/com.bilalalp/cxflogger/ -->
<dependency>
    <groupId>com.bilalalp</groupId>
    <artifactId>cxflogger</artifactId>
    <version>1.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.bilalalp/cxflogger/
implementation 'com.bilalalp:cxflogger:1.0'
// https://jarcasting.com/artifacts/com.bilalalp/cxflogger/
implementation ("com.bilalalp:cxflogger:1.0")
'com.bilalalp:cxflogger:jar:1.0'
<dependency org="com.bilalalp" name="cxflogger" rev="1.0">
  <artifact name="cxflogger" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.bilalalp', module='cxflogger', version='1.0')
)
libraryDependencies += "com.bilalalp" % "cxflogger" % "1.0"
[com.bilalalp/cxflogger "1.0"]

Dependencies

compile (12)

Group / Artifact Type Version
org.hibernate : hibernate-entitymanager jar 5.0.1.Final
com.mchange : c3p0 jar 0.9.5.1
org.springframework : spring-context jar 4.2.1.RELEASE
org.springframework : spring-orm jar 4.2.1.RELEASE
org.apache.cxf : cxf-rt-frontend-jaxws jar 3.1.2
org.apache.cxf : cxf-rt-transports-http-jetty jar 3.1.2
org.apache.cxf : cxf-rt-transports-http jar 3.1.2
org.apache.cxf : cxf-rt-bindings-soap jar 3.1.2
org.projectlombok : lombok jar 1.16.6
commons-collections : commons-collections jar 3.2.1
commons-lang : commons-lang jar 2.6
org.springframework : spring-test jar 4.2.1.RELEASE

runtime (2)

Group / Artifact Type Version
com.h2database : h2 jar 1.4.189
org.postgresql : postgresql jar 9.4-1203-jdbc42

test (3)

Group / Artifact Type Version
junit : junit jar 4.12
org.hamcrest : hamcrest-library jar 1.3
org.mockito : mockito-core jar 1.10.19

Project Modules

There are no modules declared in this project.

#Cxf Client Logger Build Status

Overview

Logging web services is a general issue for development world. This project aims to solve this issue in a different way. Many people write their own logging mechanism to log web services via interceptors. This project gets done whole dirty jobs instead of you. Our interceptors will get the job done. Web service logs will be saved to the database whether in your database or in another database. It is your choise.

Thanks for supporting Bahadır Akın.

Maven Dependency

<dependency>
  <groupId>com.bilalalp</groupId>
  <artifactId>cxfclientlogger</artifactId>
  <version>1.0</version>
</dependency>

Requirements

Library Version
Java 1.7+
Maven 3+
Spring 4.2+
Cxf 3.1+
Hibernate 5+

Build

To build the project, run mvn clean install, this will put jar file in cxfloggerprovider/target/cxfloggerprovider-1.0.jar

Usage

There are two usage scenarios.

#####1. Using a different datasource

The configuration class is com.bilalalp.cxflogger.config.CxfLoggerApplicationConfig

<bean id="cxfLoggerConfig" class="com.bilalalp.cxflogger.config.CxfLoggerApplicationConfig"/>

This will use default H2 database. You can give your own database connection informations. Here is the usage:

<context:annotation-config/>
<bean id="cxfLoggerConfig" class="com.bilalalp.cxflogger.config.CxfLoggerApplicationConfig">
    <property name="cxfLoggerConfigurationMap">
        <map>
            <entry key="cxflogger.db.jdbc.url" value="jdbc:postgresql://localhost\:5432/mydb?characterEncoding\=UTF-8"/>
            <entry key="cxflogger.db.jdbc.userName" value="postgres"/>
            <entry key="cxflogger.db.jdbc.password" value="root"/>
            <entry key="cxflogger.db.jdbc.driverClassName" value="org.postgresql.Driver"/>
        </map>
    </property>
</bean>

You can also give hibernate parameters in the same map. Below configurations are also default parameters. If you don't give any parameters, these parameters will be used. Here is the usage:

<context:annotation-config/>
<bean id="cxfLoggerConfig" class="com.bilalalp.cxflogger.config.CxfLoggerApplicationConfig">
    <property name="cxfLoggerConfigurationMap">
        <map>
            <entry key="cxflogger.db.jdbc.url" value="jdbc:h2:~/h2CxfLoggerDb;AUTO_SERVER\=TRUE"/>
            <entry key="cxflogger.db.jdbc.userName" value="postgres"/>
            <entry key="cxflogger.db.jdbc.password" value="root"/>
            <entry key="cxflogger.db.jdbc.driverClassName" value="200"/>
            <entry key="cxflogger.db.pool.maxPoolSize" value="org.postgresql.Driver"/>
            <entry key="cxflogger.db.pool.initialPoolSize" value="50"/>
            <entry key="cxflogger.db.pool.minPoolSize" value="50"/>
            <entry key="cxflogger.db.pool.incrementSize" value="2"/>
            <entry key="cxflogger.db.pool.connectionTestPeriod" value="3600"/>
            <entry key="cxflogger.db.pool.maxIdleTime" value="21600"/>
            <entry key="cxflogger.db.pool.unreturnedTimeout" value="3600"/>
            <entry key="cxflogger.db.pool.autoCommit" value="false"/>
            <entry key="cxflogger.db.pool.numHelperThreads" value="6"/>
            <entry key="cxflogger.db.pool.maxStatements" value="0"/>
            <entry key="cxflogger.db.pool.maxStatementsPerConnection" value="0"/>
            <entry key="cxflogger.db.pool.debugUnreturnedConnectionStackTraces" value="false"/>
            <entry key="cxflogger.hibernate.hbm2ddl.auto" value="update"/>
            <entry key="cxflogger.hibernate.showSql" value="false"/>
            <entry key="cxflogger.hibernate.formatSql" value="false"/>
            <entry key="cxflogger.hibernate.generate_statistics" value="false"/>
            <entry key="cxflogger.hibernate.max_fetch_depth" value="3"/>
            <entry key="cxflogger.hibernate.default_batch_fetch_size" value="16"/>
            <entry key="cxflogger.hibernate.jdbc.batch_size" value="20"/>
            <entry key="cxflogger.db.jdbc.driverClassName" value="org.postgresql.Driver"/>
        </map>
    </property>
</bean>

#####2. Using the same datasource

If you'd like to use the same datasource, here is the usage:

<context:annotation-config/>
<bean id="cxfLoggerConfig" class="com.bilalalp.cxflogger.config.CxfLoggerApplicationConfig">
    <property name="useDatasource" value="true"/>
    <property name="dataSource" ref="cxfLoggerConsumerDatasource"/>
</bean>

This will use your datasource directly, If you don't have a table named WsLog, it will be created automaticly.

After Logging configurations, you just need to add interceptors to your bus.

Here is the sample:

<bean id="abstractLoggingInterceptor" abstract="true">
    <property name="prettyLogging" value="true"/>
</bean>

<bean id="loggingInInterceptor" class="org.apache.cxf.interceptor.LoggingInInterceptor"
      parent="abstractLoggingInterceptor"/>
<bean id="loggingOutInterceptor" class="org.apache.cxf.interceptor.LoggingOutInterceptor"
      parent="abstractLoggingInterceptor"/>

<cxf:bus>
    <cxf:inInterceptors>
        <ref bean="loggingInInterceptor"/>
        <ref bean="wsLoggingInInterceptor"/>
    </cxf:inInterceptors>
    <cxf:outInterceptors>
        <ref bean="loggingOutInterceptor"/>
        <ref bean="wsLoggingOutInterceptor"/>
    </cxf:outInterceptors>
    <cxf:inFaultInterceptors>
        <ref bean="loggingInInterceptor"/>
        <ref bean="wsLoggingInInterceptor"/>
    </cxf:inFaultInterceptors>
    <cxf:outFaultInterceptors>
        <ref bean="loggingOutInterceptor"/>
        <ref bean="wsLoggingOutInterceptor"/>
    </cxf:outFaultInterceptors>
</cxf:bus>

This is it. This will store logs in wslog table.

Versions

Version
1.0