示例#1
0
        public ActionResult <string> SetLogLevel([FromBody] SetLogLevelRequest request)
        {
            LogLevelManager.SetLogLevel(request.LogLevel);
            var newLevel = LogLevelManager.GetCurrentLevel().Name;

            return(newLevel);
        }
示例#2
0
        public async Task <ActionResult> Level(string logLevel, string application)
        {
            application = application ?? string.Empty;

            if (application == CcmApplications.Web)
            {
                var wasSet = LogLevelManager.SetLogLevel(logLevel);
                if (wasSet)
                {
                    log.Info("Log level changed to {0}", logLevel);
                }
                else
                {
                    log.Info("Log level was NOT changed. ({0})", logLevel);
                }
            }
            else if (application == CcmApplications.Discovery)
            {
                var result = await SetDiscoveryLogLevelAsync(logLevel);

                if (result != logLevel)
                {
                    ViewBag.CurrentLevel = logLevel;
                    ViewBag.Application  = application;
                    return(View());
                }
            }

            return(RedirectToAction("Index", new { application }));
        }
示例#3
0
文件: Program.cs 项目: xyz37/Kats
        static int Main()
        {
            if (GS.Common.Utility.Utilities.ExistInProcess("K-Packet 통합 관리 시스템") == true)
            {
                return(-99);
            }

            Log = LogLevelManager.GetInstance(ConfigurationManager.AppSettings["logLevelPath"]);
            Log.InsertDateTime = true;
            Log.MakeDateFolder = true;

            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhadledException;
            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
            Application.ThreadException += Application_ThreadException;

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            AppSettingsHelper.Initialize(CONFIG_SECTION_NAME, CONFIG_FILENAME);

            //if (CheckConfig() == true)
            {
                Application.Run(new MainForm());
            }

            return(0);
        }
示例#4
0
        public LevelModel Get()
        {
            var currentLevel = LogLevelManager.GetCurrentLevel();

            log.Debug("Current log level is " + currentLevel.Name);
            return(new LevelModel {
                LogLevel = currentLevel.Name
            });
        }
示例#5
0
        public LevelModel Get()
        {
            var currentLevel = LogLevelManager.GetCurrentLevel();

            log.Info("Log level is '{0}' for CCM Discovery", currentLevel.Name);
            return(new LevelModel {
                LogLevel = currentLevel.Name
            });
        }
示例#6
0
        public IActionResult Index()
        {
            ViewData["Server"]      = _appSettings.Server;
            ViewData["Environment"] = _appSettings.ServerEnvironment;
            ViewData["Version"]     = "v" + _appSettings.Version;
            ViewData["ReleaseDate"] = _appSettings.ReleaseDate;
            ViewData["LogFolder"]   = _appSettings.LogFolder;
            var list = string.Join(", ", LogLevel.AllLoggingLevels.ToList().Select(l => $"\'{l.Name}\'").ToList());

            ViewData["LogLevels"]       = list;
            ViewData["CurrentLogLevel"] = LogLevelManager.GetCurrentLevel().Name;

            return(View());
        }
示例#7
0
        public LevelModel Post(LevelModel levelModel)
        {
            if (levelModel != null)
            {
                var isSet = LogLevelManager.SetLogLevel(levelModel.LogLevel);
                if (isSet)
                {
                    log.Info("Log level changed to {0}", levelModel.LogLevel);
                }
                else
                {
                    log.Info("Log level was NOT changed.");
                }
            }

            return(Get());
        }
示例#8
0
        public async Task <ActionResult> Level(string application)
        {
            application = application ?? string.Empty;
            string logLevel = "";

            if (application == CcmApplications.Web)
            {
                logLevel = LogLevelManager.GetCurrentLevel().Name;
            }
            else if (application == CcmApplications.Discovery)
            {
                logLevel = await GetDiscoveryLogLevelAsync();
            }

            ViewBag.CurrentLevel = logLevel;
            ViewBag.Application  = application;

            return(View());
        }
示例#9
0
        public async Task <ActionResult> Index(LogViewModel model)
        {
            model.Search             = model.Search ?? string.Empty;
            model.Application        = !string.IsNullOrEmpty(model.Application) ? model.Application : CcmApplications.Web;
            model.SelectedLastOption = !string.IsNullOrEmpty(model.SelectedLastOption) ? model.SelectedLastOption : GetLastOptions().First().Value;
            model.StartDateTime      = model.StartDateTime > DateTime.MinValue ? model.StartDateTime : DateTime.Now.AddHours(-6);
            model.EndDateTime        = model.EndDateTime > DateTime.MinValue ? model.EndDateTime : DateTime.Now;
            model.Rows = model.Rows > 0 ? model.Rows : 25;

            DateTime?startTime;
            DateTime?endTime;

            if (model.SelectedLastOption == "interval")
            {
                startTime = model.StartDateTime;
                endTime   = model.EndDateTime;
            }
            else
            {
                var ts = TimeSpan.Parse(model.SelectedLastOption);
                startTime = DateTime.Now.Subtract(ts);
                endTime   = null;
            }

            string logLevelCcm       = LogLevelManager.GetCurrentLevel().Name;
            string logLevelDiscovery = await GetDiscoveryLogLevelAsync();

            ViewBag.CurrentLevelCCM       = logLevelCcm;
            ViewBag.CurrentLevelDiscovery = logLevelDiscovery;

            model.LogRows = await _logRepository.GetLastAsync(model.Rows, model.Application, startTime, endTime, model.SelectedLevel, model.Search, model.ActivityId);

            model.LastOptions = GetLastOptions();
            model.Levels      = LogLevel.AllLoggingLevels.ToList().Select(l => new SelectListItem()
            {
                Value = l.Ordinal.ToString(), Text = l.Name
            });

            return(View(model));
        }