Created
March 20, 2013 21:21
-
-
Save danveloper/5208581 to your computer and use it in GitHub Desktop.
Logging Service Activator -- Real Time Logging Project
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Service | |
class LoggingServiceActivator { | |
@Autowired | |
private LoggingService loggingService | |
/** Spring Integration makes getting at the headers and payload really, really simple **/ | |
public void log(@Headers Map<String, Object> headers, @Payload LoggingEvent loggingEvent) { | |
LogMessageCommand command = new LogMessageCommand( | |
level: loggingEvent.level.toString(), | |
application: headers."application.name", | |
hostname: headers.hostname, | |
ipAddress: headers."ip-address", | |
threadName: loggingEvent.threadName, | |
message: loggingEvent.renderedMessage | |
) | |
loggingService.log(command) | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class LogMessageCommand { | |
String level | |
String threadName | |
String application | |
String message | |
String hostname | |
String ipAddress | |
LocalDateTime messageTime = new LocalDateTime() // this is joda-time | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment