Skip to content
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
1 change: 1 addition & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ endif::[]
===== Bug fixes
* Fixed multiple dropped stats types in a transaction producing invalid JSON: {pull}2589[#2589]
* Fixed NoClassDefFoundError when using OTel bridge and span.*current() : {pull}2596[#2596]
* Fallback to standard output when Security Manager prevents writing to log file - {pull}2581[#2581]

[[release-notes-1.x]]
=== Java Agent version 1.x
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,20 @@ static String getActualLogFile(@Nullable String agentHome, String logFile) {
logFile = logFile.replace(AGENT_HOME_PLACEHOLDER, agentHome);
}
}
logFile = new File(logFile).getAbsolutePath();
final File logDir = new File(logFile).getParentFile();
if (!logDir.exists()) {
logDir.mkdirs();

boolean canWrite;
try {
logFile = new File(logFile).getAbsolutePath();
final File logDir = new File(logFile).getParentFile();
if (!logDir.exists()) {
logDir.mkdirs();
}
canWrite = logDir.canWrite();
} catch (SecurityException e) {
canWrite = false;
}
if (!logDir.canWrite()) {

if(!canWrite){
System.err.println("[elastic-apm-agent] WARN Log file " + logFile + " is not writable. Falling back to System.out.");
return SYSTEM_OUT;
}
Expand Down