lib/agent/logging/am_logger.rb in site24x7_apminsight-1.8.2 vs lib/agent/logging/am_logger.rb in site24x7_apminsight-1.8.3
- old
+ new
@@ -2,25 +2,27 @@
require "logger"
module ManageEngine
class APMLogger
@apmlog=nil;
+ @apmLogPath=nil;
+
def initialize
@obj=ManageEngine::APMObjectHolder.instance
path = getLogsPath
#puts "#{path}"
if Dir[path] == []
Dir.mkdir(path)
end
- path= path + '/apm.log'
+ @apmLogPath= path + '/apm.log'
#puts "#{path}"
# file = open(path, File::WRONLY | File::APPEND | File::CREAT)
begin
- @apmlog = Logger.new(path, 10, 5 * 1024 * 1024)
+ @apmlog = Logger.new(@apmLogPath, 10, 5 * 1024 * 1024)
@apmlog.level = Logger::INFO
rescue Exception => e
- puts "Unable to create/edit the log file #{path}. Writing agent logs to STDOUT.\nError: #{e.message}"
+ puts "Unable to create/edit the log file #{@apmLogPath}. Writing agent logs to STDOUT.\nError: #{e.message}"
@apmlog = Logger.new(STDOUT)
@apmlog.level = Logger::WARN
end
# @apmlog = Logger.new(file)
@apmlog.datetime_format = "%Y-%m-%d %H:%M:%S"
@@ -29,10 +31,13 @@
end
@apmlog.debug("[LOGGER] APM Agent Logging Initialized")
end
+ def getLogFilePath
+ return @apmLogPath
+ end
def getLogsPath
props = {}
begin
if FileTest.exists?(@obj.constants.apm_conf)
@@ -57,10 +62,10 @@
#
end
if props["apminsight.log.dir"]!=nil
return props["apminsight.log.dir"]
else
- return "./log"
+ return @obj.constants.conf_location+"log"
end
end
def setLevel level