diff --git a/Projects/Config/log4net.config b/Projects/Config/log4net.config deleted file mode 100644 index b7743e6..0000000 --- a/Projects/Config/log4net.config +++ /dev/null @@ -1,85 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Projects/DLL/System.Configuration.ConfigurationManager.dll b/Projects/DLL/System.Configuration.ConfigurationManager.dll deleted file mode 100644 index 14f8ef6..0000000 Binary files a/Projects/DLL/System.Configuration.ConfigurationManager.dll and /dev/null differ diff --git a/Projects/DLL/log4net.dll b/Projects/DLL/log4net.dll deleted file mode 100644 index a11cb29..0000000 Binary files a/Projects/DLL/log4net.dll and /dev/null differ diff --git a/Projects/WebApi/AuthApi/Controllers/AuthController.cs b/Projects/WebApi/AuthApi/Controllers/AuthController.cs index 7ea8a44..db71bef 100644 --- a/Projects/WebApi/AuthApi/Controllers/AuthController.cs +++ b/Projects/WebApi/AuthApi/Controllers/AuthController.cs @@ -31,7 +31,7 @@ namespace AuthApi.Controllers [HttpGet("health")] public async Task Health() { - Log4net.WriteLine($"[{GetRequestMethod()}:{GetMethodName()}] [Client IP:{GetClientIP()}] [RequestUrl:{GetRequestUrl()}]{Environment.NewLine}", LogType.CONTROLLER); + LogXnet.WriteLine($"[{GetRequestMethod()}:{GetMethodName()}] [Client IP:{GetClientIP()}] [RequestUrl:{GetRequestUrl()}]{Environment.NewLine}", LogXLabel.CONTROLLER); await Task.CompletedTask; return Results.Ok("Healthy"); @@ -42,7 +42,7 @@ namespace AuthApi.Controllers { Guid guid = Guid.NewGuid(); - Log4net.WriteLine($"[Request][{GetRequestMethod()}:{GetMethodName()}][Client IP:{GetClientIP()}][RequestUrl:{GetRequestUrl()}]::({guid}){Environment.NewLine} {request.ToJson()}", LogType.CONTROLLER); + LogXnet.WriteLine($"[Request][{GetRequestMethod()}:{GetMethodName()}][Client IP:{GetClientIP()}][RequestUrl:{GetRequestUrl()}]::({guid}){Environment.NewLine} {request.ToJson()}", LogXLabel.CONTROLLER); RegisterResponse response = new RegisterResponse(); if (request?.UserID != null && request?.Password != null) @@ -50,7 +50,7 @@ namespace AuthApi.Controllers response = await _authService.CreateUser(request); } - Log4net.WriteLine($"[Response]::({guid}){Environment.NewLine} {response.ToJson()}", LogType.CONTROLLER); + LogXnet.WriteLine($"[Response]::({guid}){Environment.NewLine} {response.ToJson()}", LogXLabel.CONTROLLER); return Results.Ok(response); } @@ -58,7 +58,7 @@ namespace AuthApi.Controllers [HttpPost("login")] public async Task Login([FromBody] Login request) { - Log4net.WriteLine($"[Request]({guid}) api/auth/register{Environment.NewLine} {request.ToJson()}", LogType.CONTROLLER); + LogXnet.WriteLine($"[Request]({guid}) api/auth/register{Environment.NewLine} {request.ToJson()}", LogXLabel.CONTROLLER); LoginResponse response = new LoginResponse(); response.UserID = request.UserID; @@ -81,7 +81,7 @@ namespace AuthApi.Controllers await _authService.UpdateLoginInfo(request, response.RefreshToken); } - Log4net.WriteLine($"[Response]({guid}) api/auth/register{Environment.NewLine} {response.ToJson()}", LogType.CONTROLLER); + LogXnet.WriteLine($"[Response]({guid}) api/auth/register{Environment.NewLine} {response.ToJson()}", LogXLabel.CONTROLLER); return Results.Ok(response); } @@ -89,12 +89,12 @@ namespace AuthApi.Controllers [HttpPost("logout")] public async Task Logout([FromBody] Logout request) { - Log4net.WriteLine($"[Request]({guid}) api/auth/register{Environment.NewLine} {request.ToJson()}", LogType.CONTROLLER); + LogXnet.WriteLine($"[Request]({guid}) api/auth/register{Environment.NewLine} {request.ToJson()}", LogXLabel.CONTROLLER); var response = _authService.LogoutUser(request); await Task.CompletedTask; - Log4net.WriteLine($"[Response]({guid}) api/auth/register{Environment.NewLine} {response.ToJson()}", LogType.CONTROLLER); + LogXnet.WriteLine($"[Response]({guid}) api/auth/register{Environment.NewLine} {response.ToJson()}", LogXLabel.CONTROLLER); return Results.Ok(response); } diff --git a/Projects/WebApi/AuthApi/Program.cs b/Projects/WebApi/AuthApi/Program.cs index cd0e835..60c7c89 100644 --- a/Projects/WebApi/AuthApi/Program.cs +++ b/Projects/WebApi/AuthApi/Program.cs @@ -14,14 +14,13 @@ string configDir = @"../../Config"; string configFileName = "WebApi.AuthApi.Config.json"; //raed log4net configs -if (Log4net.IsConfigLoad == true) +if (LogXnet.ReadConfig(@$"{configDir}/LogXnetConfig.json") == true) { - Log4net.WriteLine("Log4net Init Success"); - Log4net.AutoRemoveLog(); + LogXnet.WriteLine("LogXnet Init Success"); } else { - Console.WriteLine("Log4net Init Failed"); + Console.WriteLine("LogXnet Init Failed"); return; } @@ -73,7 +72,7 @@ if (preloadConfig.OpenConfig($@"{configDir}/{configFileName}") == true) } else { - Log4net.WriteLine("Config Preload Load Error.", LogType.Error); + LogXnet.WriteLine("Config Preload Load Error.", LogXLabel.Error); return; } @@ -86,7 +85,7 @@ bool isIIS = false; if (configService?.OpenConfig($@"{configDir}/{configFileName}") == true) { - Log4net.WriteLine("WebApi Config Success."); + LogXnet.WriteLine("WebApi Config Success."); var apiConfig = ConfigService.Config; if (apiConfig != null) { @@ -114,15 +113,15 @@ if (configService?.OpenConfig($@"{configDir}/{configFileName}") == true) } else { - Log4net.WriteLine("WebApi Config Error."); + LogXnet.WriteLine("WebApi Config Error."); return; } // Configure the HTTP request pipeline. if (app.Environment.IsDevelopment()) { - Log4net.WriteLine($"IsDevelopment:{app.Environment.IsDevelopment()}"); - Log4net.WriteLine($"Swagger Url: {serverUrl}/swagger"); + LogXnet.WriteLine($"IsDevelopment:{app.Environment.IsDevelopment()}"); + LogXnet.WriteLine($"Swagger Url: {serverUrl}/swagger"); app.UseSwagger(); app.UseSwaggerUI(); } @@ -139,6 +138,6 @@ if (isIIS == true) } else { - Log4net.WriteLine($"Operation Url: {serverUrl}"); + LogXnet.WriteLine($"Operation Url: {serverUrl}"); app.Run($"{serverUrl}"); } diff --git a/Projects/WebApi/AuthApi/Services/AuthService.cs b/Projects/WebApi/AuthApi/Services/AuthService.cs index 29583ce..ec601de 100644 --- a/Projects/WebApi/AuthApi/Services/AuthService.cs +++ b/Projects/WebApi/AuthApi/Services/AuthService.cs @@ -154,15 +154,15 @@ namespace AuthApi.Services else { response.EC = ERROR_CODE.EC_USER_LOGIN_NOT_EXIST; - Log4net.WriteLine($"{response.EC}", LogType.Error); + LogXnet.WriteLine($"{response.EC}", LogXLabel.Error); } await context.CloseTransactionAsync(transaction); } } catch (Exception e) { - Log4net.WriteLine($"Select User Transaction Error", LogType.Exception); - Log4net.WriteLine(e); + LogXnet.WriteLine($"Select User Transaction Error", LogXLabel.Exception); + LogXnet.WriteLine(e); } } } @@ -215,13 +215,13 @@ namespace AuthApi.Services } //commit - Log4net.WriteLine(findRefreshToken?.ToJson(), LogType.Debug); + LogXnet.WriteLine($"{findRefreshToken?.ToJson()}", LogXLabel.Debug); result = true; } catch (Exception ex) { - Log4net.WriteLine(ex); + LogXnet.WriteLine(ex); } transactionResult = await context.CloseTransactionAsync(transaction); @@ -229,17 +229,17 @@ namespace AuthApi.Services } else { - Log4net.WriteLine($"Not Exist User {loginModel.UserID}", LogType.Error); + LogXnet.WriteLine($"Not Exist User {loginModel.UserID}", LogXLabel.Error); } //db error if (transactionResult == false) { - Log4net.WriteLine($"Transaction Error", LogType.Error); + LogXnet.WriteLine($"Transaction Error", LogXLabel.Error); } else { - Log4net.WriteLine($"Transaction Success", LogType.DB); + LogXnet.WriteLine($"Transaction Success", LogXLabel.DB); } } }