Skip to content

Instantly share code, notes, and snippets.

@danveloper
Created March 20, 2013 21:21
Show Gist options
  • Save danveloper/5208581 to your computer and use it in GitHub Desktop.
Save danveloper/5208581 to your computer and use it in GitHub Desktop.
Logging Service Activator -- Real Time Logging Project
@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)
}
}
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