Spring Extention Logging

Extension to log every incomming/outgoing http request etc. with Log4J due an spring interceptor and configure it once.

Лицензия

Лицензия

Категории

Категории

Logging Библиотеки уровня приложения
Группа

Группа

io.winkelmann
Идентификатор

Идентификатор

spring-extension-logging
Последняя версия

Последняя версия

1.0.1
Дата

Дата

Тип

Тип

jar
Описание

Описание

Spring Extention Logging
Extension to log every incomming/outgoing http request etc. with Log4J due an spring interceptor and configure it once.
Ссылка на сайт

Ссылка на сайт

https://github.com/mwinkelmann/spring-extension-logging
Система контроля версий

Система контроля версий

https://github.com/mwinkelmann/spring-extension-logging

Скачать spring-extension-logging

Как подключить последнюю версию

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

Зависимости

compile (4)

Идентификатор библиотеки Тип Версия
org.springframework : spring-webmvc jar 4.3.2.RELEASE
javax.servlet : javax.servlet-api jar 3.1.0
org.slf4j : slf4j-api jar 1.7.21
org.projectlombok : lombok jar 1.16.10

Модули Проекта

Данный проект не имеет модулей.

Spring Logging Interceptor

... was build for every Spring developer and needs to be placed in every spring project! :)

##About This is a small library for Spring which will give you the ability to add a logging interceptor to spring to log all http requests. You could also configure a lot for the logging interceptor e.g. what should be logged, when should the log appear, ...

##How to use?? You only need to add this Interceptor to your spring contexts InterceptorRegistry. In Spring Boot you only need to override the addInterceptors in your service starter.

@SpringBootApplication
public class WebApplicationStarter extends WebMvcConfigurerAdapter {
...
     @Override
        public void addInterceptors(InterceptorRegistry registry) {
            registry.addInterceptor(new LoggingInterceptor());
        }
... 
}

For older Spring versions you also need to add this interceptor to your available interceptor registry/list but in a little bit different way. If you have some questions for it feel free to ask me.

##Configuration You could configure how your logs should look like. There are some uniform events which will be triggered by spring. For every event/method you could configure a log pattern({eventName}LogPattern) and a log level this message should be logged({eventName}LogLevel)

###Configurable Replacements All replacement strings are documented in this file - LogField.java

###pre handle This method will be called after HandlerMapping determined an appropriate handler object, but before HandlerAdapter invokes the handler

  • preHandleLogPattern - Log pattern you want to have replaced and logged in PRE_HANDLE [Default: Method: %http_request_method% - RequestURI: %http_request_uri% - RequestURL: %http_request_url% - Runtime: %request_runtime%ms - RequestedSessionId: %http_request_session_id% - CreatedSessionId: %http_request_created_session_id%]

  • preHandleLogLevel - specify the LogLevel the log should appear [Default: debug] ###post handle This method will be called after HandlerAdapter actually invoked the handler, but before the DispatcherServlet renders the view.

  • postHandleLogPattern - Log pattern you want to have replaced and logged in POST_HANDLE [Default: Method: %http_request_method% - RequestURI: %http_request_uri% - HttpStatus: %http_response_status% - Runtime: %request_runtime%ms]

  • postHandleLogLevel - specify the LogLevel the log should appear [Default: debug] ###after completion This method will be called after completion of request processing, that is, after rendering the view.

  • afterCompletionLogPattern - Log pattern you want to have replaced and logged in AFTER_COMPLETION
    [Default: Method: %http_request_method% - RequestURI: %http_request_uri% - RequestParams: %http_request_params% - HttpStatus: %http_response_status% - Runtime: %request_runtime%ms]

  • afterCompletionLogLevel - specify the LogLevel the log should appear [Default: info] ##Maven Current version is available at central repository

    ... io.winkelmann spring-extension-logging {CURRENT_VERSION} ...

For the current version take a look at the maven central page: https://mvnrepository.com/artifact/io.winkelmann/spring-extension-logging

###TODO

  • add tests
  • make logging level settable
  • some performance tests

Версии библиотеки

Версия
1.0.1
1.0.0