Skip to content
This repository has been archived by the owner on Aug 30, 2019. It is now read-only.

Commit

Permalink
Merge pull request #335 from bmermet/fixwindowslogpath
Browse files Browse the repository at this point in the history
Change default log path on Windows
  • Loading branch information
Emanuele Palazzetti committed Nov 14, 2017
2 parents 9903528 + c289b09 commit f936579
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
11 changes: 5 additions & 6 deletions agent/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ import (

log "github.com/cihub/seelog"

"github.com/DataDog/datadog-trace-agent/config"
"github.com/DataDog/datadog-trace-agent/watchdog"
)

const defaultLogFilePath = "/var/log/datadog/trace-agent.log"

const agentLoggerConfigFmt = `
<seelog minlevel="%[1]s">
<outputs formatid="agent">
Expand Down Expand Up @@ -198,15 +197,15 @@ func SetupLogger(minLogLvl log.LogLevel, logFilePath string, logsDropInterval ti
log.RegisterReceiver("throttled", &ThrottledReceiver{})

// Build our config string
config := fmt.Sprintf(
logConfig := fmt.Sprintf(
agentLoggerConfigFmt,
minLogLvl,
logsDropInterval,
logsDropMaxPerInterval,
logFilePath,
)

logger, err := log.LoggerFromConfigAsString(config)
logger, err := log.LoggerFromConfigAsString(logConfig)
if err != nil {
return err
}
Expand All @@ -216,9 +215,9 @@ func SetupLogger(minLogLvl log.LogLevel, logFilePath string, logsDropInterval ti
// SetupDefaultLogger sets up a default logger for the agent, showing
// all log messages and with no throttling.
func SetupDefaultLogger() error {
config := fmt.Sprintf(rawLoggerConfigFmt, defaultLogFilePath)
logConfig := fmt.Sprintf(rawLoggerConfigFmt, config.DefaultLogFilePath)

logger, err := log.LoggerFromConfigAsString(config)
logger, err := log.LoggerFromConfigAsString(logConfig)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion config/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ func NewDefaultAgentConfig() *AgentConfig {
StatsdPort: 8125,

LogLevel: "INFO",
LogFilePath: "/var/log/datadog/trace-agent.log",
LogFilePath: DefaultLogFilePath,
LogThrottlingEnabled: true,

MaxMemory: 5e8, // 500 Mb, should rarely go above 50 Mb
Expand Down
6 changes: 6 additions & 0 deletions config/agent_nix.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// +build !windows

package config

// DefaultLogFilePath is where the agent will write logs if not overriden in the conf
const DefaultLogFilePath = "/var/log/datadog/trace-agent.log"
4 changes: 4 additions & 0 deletions config/agent_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package config

// DefaultLogFilePath is where the agent will write logs if not overriden in the conf
const DefaultLogFilePath = "c:\\programdata\\datadog\\logs\\trace-agent.log"

0 comments on commit f936579

Please sign in to comment.