File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed
dotnet/src/dotnetframework/GxClasses/Diagnostics Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change 11using GeneXus . Attributes ;
22using GeneXus . Configuration ;
33using log4net ;
4+ using System . Collections . Concurrent ;
5+
46#if NETCORE
57using GeneXus . Services . Log ;
68using Microsoft . Extensions . Logging ;
@@ -26,17 +28,19 @@ private enum LogLevel
2628 private static readonly string DefaultRepository = LogManager . GetRepository ( ) . Name ;
2729 private static readonly string DefaultUserLogNamespace = Config . GetValueOf ( "USER_LOG_NAMESPACE" , LogConfiguration . USER_LOG_TOPIC ) ;
2830 private static readonly IGXLogger GlobalLog = new GXLoggerLog4Net ( LogManager . GetLogger ( DefaultRepository , DefaultUserLogNamespace ) ) ;
29-
31+ private static ConcurrentDictionary < string , IGXLogger > LoggerDictionary = new ConcurrentDictionary < string , IGXLogger > ( ) { [ string . Empty ] = GlobalLog } ;
3032 internal static IGXLogger GetLogger ( string topic )
3133 {
32- if ( ! string . IsNullOrEmpty ( topic ) )
34+ if ( LoggerDictionary . TryGetValue ( topic , out IGXLogger logger ) )
3335 {
34- string loggerName = topic . StartsWith ( LoggerPrefix ) ? topic . Substring ( 1 ) : $ "{ DefaultUserLogNamespace } .{ topic . Trim ( ) } ";
35- return GXLoggerFactory . GetLogger ( loggerName ) ;
36+ return logger ;
3637 }
3738 else
3839 {
39- return GlobalLog ;
40+ string loggerName = topic . StartsWith ( LoggerPrefix ) ? topic . Substring ( 1 ) : $ "{ DefaultUserLogNamespace } .{ topic . Trim ( ) } ";
41+ logger = GXLoggerFactory . GetLogger ( loggerName ) ;
42+ LoggerDictionary . TryAdd ( topic , logger ) ;
43+ return logger ;
4044 }
4145 }
4246
You can’t perform that action at this time.
0 commit comments