Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st.
We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here.
Need help or have questions? Drop us a line at [email protected]
Created 09-25-2015 06:35 PM
For Ambari-Server, I currently make adjustments to:
/etc/ambari-server/conf/log4j.properties
And for the Agent, I have to create a symlink to redirect /var/log/ambari-agent.
Is there a better method?
Created 10-28-2015 03:16 AM
For ambari-agent, use the $AMBARI_AGENT_LOG_DIR environment variable. There is a typo in /usr/sbin/ambari-agent shell script though:
Just change $AMBARI_LOG_DIR to $AMBARI_AGENT_LOG_DIR in /usr/sbin/ambari-agent. Now set $AMBARI_AGENT_LOG_DIR to the desired location.
The bug has been fixed in trunk: https://reviews.apache.org/r/37990/
For ambari-server, there is no such environment variable. I'll file a bug for this and have it triaged.
Created 09-25-2015 07:12 PM
@[email protected] David for ambari-agent the "LOGFILE" directory is hardcoded in the /usr/sbin/ambari-agent which is called directly from the ambari-agent start script. It isn't possible right now to paramatize this value. You could change the value of "LOGFILE" in /usr/sbin/ambari-agent but using a symlink is the probably the best option. "LOGFILE" is located on line 45.
LOGFILE=/var/log/ambari-agent/ambari-agent.log
Created 09-25-2015 07:23 PM
David after looking a little more closely I was wrong. You can specify the ambari-agent logging directory (but not file name) using the environment variable "AMBARI_AGENT_LOG_DIR". Hope that helps
Created 09-25-2015 07:38 PM
If you feel like hacking, I think you can also do this via AmbariConfig.py:
ambari-agent.log:
/usr/lib/python2.6/site-packages/ambari_agent/AmbariConfig.py:
@staticmethod
def getLogFile():
if 'AMBARI_AGENT_LOG_DIR' in os.environ:
return os.path.join(os.environ['AMBARI_AGENT_LOG_DIR'], "ambari-agent.log")
else:
# return os.path.join(os.sep, "var", "log", "ambari-agent", "ambari-agent.log")
return "/new_log_dir/ambari-agent.log"
ambari-agent.out:
/usr/lib/python2.6/site-packages/ambari_agent/AmbariConfig.py:
@staticmethod
def getOutFile():
if 'AMBARI_AGENT_OUT_DIR' in os.environ:
return os.path.join(os.environ['AMBARI_AGENT_OUT_DIR'], "ambari-agent.out")
else:
# return os.path.join(os.sep, "var", "log", "ambari-agent", "ambari-agent.out")
return "/new_log_dir/ambari-agent.out"
ambari-server.out:
/usr/lib/python2.6/site-packages/ambari_server/serverConfiguration.py:
class ServerConfigDefaults(object):
def __init__(self):
self.JAVA_SHARE_PATH = "/usr/share/java"
# self.OUT_DIR = os.sep + os.path.join("var", "log", "ambari-server")
self.OUT_DIR = os.sep + os.path.join("new_log_dir", "ambari-server")
self.SERVER_OUT_FILE = os.path.join(self.OUT_DIR, "ambari-server.out")
self.SERVER_LOG_FILE = os.path.join(self.OUT_DIR, "ambari-server.log")
self.ROOT_FS_PATH = os.sep
ambari-server.log:
vi /etc/ambari-server/conf/log4j.properties:
# Direct log messages to a log file
log4j.appender.file=org.apache.log4j.RollingFileAppender
#log4j.appender.file.File=/var/log/ambari-server/ambari-server.log
log4j.appender.file.File=/new_log_dir/ambari-server.log
log4j.appender.file.MaxFileSize=80MB
log4j.appender.file.MaxBackupIndex=60
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{DATE} %5p [%t] %c{1}:%L - %m%n
Created 10-28-2015 03:16 AM
For ambari-agent, use the $AMBARI_AGENT_LOG_DIR environment variable. There is a typo in /usr/sbin/ambari-agent shell script though:
Just change $AMBARI_LOG_DIR to $AMBARI_AGENT_LOG_DIR in /usr/sbin/ambari-agent. Now set $AMBARI_AGENT_LOG_DIR to the desired location.
The bug has been fixed in trunk: https://reviews.apache.org/r/37990/
For ambari-server, there is no such environment variable. I'll file a bug for this and have it triaged.