remote_syslog2 icon indicating copy to clipboard operation
remote_syslog2 copied to clipboard

Create an includes_patterns for explicit log lines

Open shadowbq opened this issue 7 years ago • 1 comments

There are situations where we dont want the entire log file, (catalina/tomcat) to dump into remote syslog.

I know there was a previous issue thar was complicated, but this could just be implemented with a config that fails if both includes_patterns and excludes_patterns both exist to at least add value.

shadowbq avatar Oct 30 '18 17:10 shadowbq

type Config struct {		
    [..]
    IncludePatterns      []*regexp.Regexp `mapstructure:"include_patterns"`
    [..]
}
    if ( s.config.IncludePatterns blah blah is set )
        {
            if matchExps(l, s.config.IncludePatterns) {

                s.logger.Write(syslog.Packet{
                    Severity: s.config.Severity,
                    Facility: s.config.Facility,
                    Time:     time.Now(),
                    Hostname: s.logger.ClientHostname,
                    Tag:      tag,
                    Message:  l,
                })

                log.Tracef("Forwarding line: %s", l)

            } else {
                log.Tracef("Not Forwarding line: %s", l)
            }
        }
    else 
        {
            if !matchExps(l, s.config.ExcludePatterns) {

                s.logger.Write(syslog.Packet{
                    Severity: s.config.Severity,
                    Facility: s.config.Facility,
                    Time:     time.Now(),
                    Hostname: s.logger.ClientHostname,
                    Tag:      tag,
                    Message:  l,
                })

                log.Tracef("Forwarding line: %s", l)

            } else {
                log.Tracef("Not Forwarding line: %s", l)
            }
        }

shadowbq avatar Oct 30 '18 18:10 shadowbq