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

Change default log path on Windows #335

Merged
merged 1 commit into from
Nov 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@derekwbrown can you confirm?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm