Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvements to logging (#3262) #3267

Merged
merged 17 commits into from
Apr 5, 2017
Merged

Improvements to logging (#3262) #3267

merged 17 commits into from
Apr 5, 2017

Conversation

ketan
Copy link
Member

@ketan ketan commented Mar 15, 2017

No description provided.

@ketan ketan force-pushed the improve/loggging branch 9 times, most recently from 297f733 to 452a8d8 Compare March 16, 2017 06:25
@varshavaradarajan
Copy link
Contributor

varshavaradarajan commented Mar 27, 2017

  • stop-agent.sh - Change the LOG_FILE path to $AGENT_WORK_DIR/logs/agent-bootstrapper.log
  • the path for autoregister.properties, guid.txt etc is hardcoded to be config directory. Make the config directory configurable on the agent side as well. This will involve change agent.sh to include the system property cruise.config.dir as a startup argument

@ketan ketan added this to the Release 17.4 milestone Mar 31, 2017
@jyotisingh
Copy link
Contributor

Did not test it by bringing up an agent, but the code looks good to me..about the deletion of agent manifest file have you checked if the packaged agent MANIFEST file continues to include all the required info. This is what I see in the current version:

Manifest-Version: 1.0
Go-Version: 17.4.0-4712
Implementation-Title: agent
Target-Compatibility: 1.8
Implementation-Version: 17.4.0-4712
Source-Compatibility: 1.8
Go-Agent-Bootstrap-Class: com.thoughtworks.go.agent.AgentProcessParent
 Impl
Go-Revision: c943bb57d7d7d18c1d3cf9a9bd3385d56edbdd37
ImplementationVersion: 17.4.0-4712
Main-Class: com.simontuffs.onejar.Boot
One-Jar-Main-Class: com.thoughtworks.go.agent.AgentMain

@ketan
Copy link
Member Author

ketan commented Mar 31, 2017

have you checked if the packaged agent MANIFEST file continues to include all the required info

All jars are packaged via the Jar gradle task, and MANIFEST.MF content defined in the task itself. None of them slurp in configuration from a MANIFEST.MF file.

@jyotisingh
Copy link
Contributor

Then I guess its all good.

@jyotisingh
Copy link
Contributor

the only thing is build hasn't run, so may be you would want to see that through, esp. the functional tests

@@ -39,8 +40,9 @@

public class DevelopmentServer {
public static void main(String[] args) throws Exception {
LogConfigurator logConfigurator = new LogConfigurator(DEFAULT_LOG4J_CONFIGURATION_FILE);
logConfigurator.initialize();
Copy link
Contributor

Choose a reason for hiding this comment

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

No need for this. LoggingInitializer will take care of it. The statement Could not find file 'config/log4j.properties'. Attempting to load from classpath. appears twice otherwise

Copy link
Member Author

Choose a reason for hiding this comment

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

This happens because the main program uses a different classloader than the webapp. So the logger is actually initialized twice. Side-effect of how logging is setup, unfortunately nothing (simple) that can be done about it.

fi

mkdir -p "${LOG_DIR}"

STDOUT_LOG_FILE=$LOG_DIR/${SERVICE_NAME}-bootstrapper.out.log
Copy link
Contributor

Choose a reason for hiding this comment

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

There is a LOG_FILE variable that is exported unnecessarily and stop-agent.sh also sets it unnecessarily. I did a git grep -w "LOG_FILE" in the project and found no usages in the code, except for JavaApplicationStub64. I think we can remove it.

Copy link
Member Author

@ketan ketan left a comment

Choose a reason for hiding this comment

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

@varshavaradarajan @jyotisingh — I think I'm done submitting additional changes to this PR. You probably want to see the last 5 commits —

  • 30f2c13 - Remove declaration of unwanted LOG_FILE environment variable. (6 minutes ago)
  • 45ff550 - Remove deprecated AGENT_TRUST_FILE constant. (6 minutes ago)
  • 4f6e8ef - Remove hard-coded config dir and use the one defined in SystemEnvironment instead (6 minutes ago)
  • 5aa840c - Ignore the log dir (6 minutes ago)
  • 35c8090 - Change log dir to logs (6 minutes ago)

@@ -39,8 +40,9 @@

public class DevelopmentServer {
public static void main(String[] args) throws Exception {
LogConfigurator logConfigurator = new LogConfigurator(DEFAULT_LOG4J_CONFIGURATION_FILE);
logConfigurator.initialize();
Copy link
Member Author

Choose a reason for hiding this comment

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

This happens because the main program uses a different classloader than the webapp. So the logger is actually initialized twice. Side-effect of how logging is setup, unfortunately nothing (simple) that can be done about it.

@@ -55,7 +55,6 @@ clean.doFirst {
delete 'agent-plugins.zip'
delete 'tfs-impl.jar'
delete 'go-agent.log'
Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't this have to be logs directory now?

@varshavaradarajan
Copy link
Contributor

@ketan, https://github.com/gocd/gocd/blob/master/agent-launcher/test/com/thoughtworks/go/agent/launcher/AgentLauncherImplTest.java#L64 needs to change lest it leaves behind a the logs directory during cleanup?

@ketan ketan force-pushed the improve/loggging branch 2 times, most recently from af06677 to d84b7f3 Compare April 5, 2017 05:08
ketan and others added 6 commits April 5, 2017 10:38
* this will look for a log file in the current working directory
* in case the file is not found, will look for the same file in the
  classpath
* in case of missing classpath resource, will fallback to configure
  logging to STDOUT at INFO level
Spring was initializing the logger, which might have been too late in
case some component failed early.
@ketan ketan merged commit af91a90 into gocd:master Apr 5, 2017
@zabil zabil removed the in progress label Apr 5, 2017
@ketan ketan deleted the improve/loggging branch April 13, 2017 12:55
@jyotisingh jyotisingh mentioned this pull request Apr 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants