清理编译文件,修改netty日志配置

master
smartwyy 6 months ago
parent 7bf5befb50
commit ea40679cdf

25
.gitignore vendored

@ -1,13 +1,6 @@
/.idea/** /.idea/**
**/obj/
**/bin/
.vs/ .vs/
WebStarter/obj
WebStarter/bin
WinFormStarter/obj
WinFormStarter/bin
/HybirdFrameworkCore/obj/
## Ignore Visual Studio temporary files, build results, and ## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons. ## files generated by popular Visual Studio add-ons.
@ -29,21 +22,7 @@ WinFormStarter/bin
mono_crash.* mono_crash.*
# Build results # Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Ww][Ii][Nn]32/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Oo]ut/
[Ll]og/
[Ll]ogs/
# Visual Studio 2015/2017 cache/options directory # Visual Studio 2015/2017 cache/options directory
.vs/ .vs/
@ -373,3 +352,5 @@ MigrationBackup/
# Fody - auto-generated XML schema # Fody - auto-generated XML schema
FodyWeavers.xsd FodyWeavers.xsd

@ -193,7 +193,11 @@ public class ChargerClient : TcpClient<IBaseHandler, Decoder, Encoder>
private ILog Log() private ILog Log()
{ {
return LogManager.GetLogger("charger_" + this.Sn); var name = "Charger" + this.Sn;
ILog logger = LogManager.GetLogger(name);
Console.WriteLine(name + "-" + logger.GetHashCode());
return logger;
} }
/// <summary> /// <summary>
@ -547,6 +551,7 @@ public class ChargerClient : TcpClient<IBaseHandler, Decoder, Encoder>
public bool Connect() public bool Connect()
{ {
base.BaseConnect(); base.BaseConnect();
Log().Info($"charger {Sn} connect succeed");
return Connected; return Connected;
} }

@ -94,6 +94,7 @@ public static class ClientMgr
client.Sn = netInfo.Code; client.Sn = netInfo.Code;
client.BinNo = binInfo?.No; client.BinNo = binInfo?.No;
client.BatteryNo = binInfo?.BatteryNo; client.BatteryNo = binInfo?.BatteryNo;
client.LogName = "Charger" + netInfo.Code;
client.ConnectedEventHandler += (sender, b) => client.SendAuth(); client.ConnectedEventHandler += (sender, b) => client.SendAuth();
client.InitBootstrap(netInfo.NetAddr, int.Parse(netInfo.NetPort)); client.InitBootstrap(netInfo.NetAddr, int.Parse(netInfo.NetPort));

@ -22,7 +22,7 @@ public class Decoder : ByteToMessageDecoder
{ {
if (ObjUtils.IsNotNullOrWhiteSpace(chargerSn)) if (ObjUtils.IsNotNullOrWhiteSpace(chargerSn))
{ {
LogManager.GetLogger("charger_" + chargerSn); return LogManager.GetLogger("Charger" + chargerSn);
} }
return LogManager.GetLogger(typeof(Decoder)); return LogManager.GetLogger(typeof(Decoder));
} }

@ -15,13 +15,13 @@ namespace Service.Charger.Codec;
/// </summary> /// </summary>
public class Encoder : MessageToByteEncoder<APCI> public class Encoder : MessageToByteEncoder<APCI>
{ {
private ILog Log(string? chargerSn) private ILog? Log(string? chargerSn)
{ {
if (ObjUtils.IsNotNullOrWhiteSpace(chargerSn)) if (ObjUtils.IsNotNullOrWhiteSpace(chargerSn))
{ {
LogManager.GetLogger("charger_" + chargerSn); return LogManager.GetLogger("Charger" + chargerSn);
} }
return LogManager.GetLogger(typeof(Decoder)); return LogManager.GetLogger(typeof(Encoder));
} }
/// <summary> /// <summary>
@ -41,7 +41,7 @@ public class Encoder : MessageToByteEncoder<APCI>
} }
byte[] bytes = obj.ToBytes(); byte[] bytes = obj.ToBytes();
Log(sn).Info($"send {BitUtls.BytesToHexStr(bytes)}:{JsonConvert.SerializeObject(obj)} to {ChannelUtils.GetAttr(context.Channel, ChargerConst.ChargerSn)}"); Log(sn)?.Info($"send {BitUtls.BytesToHexStr(bytes)}:{JsonConvert.SerializeObject(obj)} to {ChannelUtils.GetAttr(context.Channel, ChargerConst.ChargerSn)}");
output.WriteBytes(bytes); output.WriteBytes(bytes);
} }

@ -2,7 +2,7 @@
"ConnectionStrings": { "ConnectionStrings": {
"ConfigId": "master", "ConfigId": "master",
"DbType": "MySql", "DbType": "MySql",
"SqlConnection": "server=192.168.2.2;Port=3306;Database=huanneng_dev;Uid=root;Pwd=Rszn123;Charset=utf8;" "SqlConnection": "server=180.76.133.253;Port=16306;Database=huanneng_dev;Uid=root;Pwd=Rszn123;Charset=utf8;"
}, },
"Update": { "Update": {
"AutoUpdate": "false", "AutoUpdate": "false",

@ -1,19 +0,0 @@
{
"runtimeOptions": {
"tfm": "net6.0",
"frameworks": [
{
"name": "Microsoft.NETCore.App",
"version": "6.0.0"
},
{
"name": "Microsoft.AspNetCore.App",
"version": "6.0.0"
}
],
"configProperties": {
"System.GC.Server": true,
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
}
}
}

@ -1,24 +0,0 @@
{
"ConnectionStrings": {
"ConfigId": "master",
"DbType": "MySql",
"SqlConnection": "server=127.0.0.1;Port=3306;Database=huanneng_dev;Uid=root;Pwd=anyixing2023!@#;Charset=utf8;"
},
"Update": {
"AutoUpdate": "false",
"Version": "1.1.0.1",
"Url": "http://121.4.95.243:8090/Updates/AutoUpdaterStarter.xml"
},
"Redis": {
"Connection": "106.12.36.89:6379,password=123456",
"InstanceName": "local",
"DefaultDB": "8"
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}

@ -1,179 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<log4net>
<!-- 控制台日志配置 -->
<appender name="Console" type="log4net.Appender.ConsoleAppender">
<!-- 日志输出格式 -->
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date %5level [%thread] (%file:%line) - %message%newline" />
</layout>
</appender>
<!-- 文件存储日志配置 -->
<appender name="RollingFile" type="log4net.Appender.RollingFileAppender">
<!-- 保存文件的名称 -->
<file value="logs\WebApi.log" />
<appendToFile value="true" />
<!-- 文件的编码方式 -->
<param name="Encoding" value="UTF-8" />
<!-- 每个文件的大小 -->
<maximumFileSize value="100MB" />
<!-- 保存文件数量 -->
<maxSizeRollBackups value="2" />
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
<!-- 日志输出格式 -->
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date %level %thread %logger - %message%newline" />
</layout>
</appender>
<logger name="Charger1" additivity="false">
<level value="ALL" />
<appender-ref ref="Charger1" />
</logger>
<appender name="Charger1" type="log4net.Appender.RollingFileAppender">
<param name="File" value="logs\Charger\" />
<param name="AppendToFile" value="true" />
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
<Encoding value="UTF-8" />
<param name="StaticLogFileName" value="false" />
<param name="RollingStyle" value="Composite" />
<param name="DatePattern" value="yyyyMMdd/HH&quot;Charger1.log&quot;" />
<param name="maximumFileSize" value="200MB" />
<param name="MaxSizeRollBackups" value="5" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date %level %thread %logger - %message%newline" />
</layout>
</appender>
<logger name="Charger2" additivity="false">
<level value="ALL" />
<appender-ref ref="Charger2" />
</logger>
<appender name="Charger2" type="log4net.Appender.RollingFileAppender">
<param name="File" value="logs\Charger\" />
<param name="AppendToFile" value="true" />
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
<Encoding value="UTF-8" />
<param name="StaticLogFileName" value="false" />
<param name="RollingStyle" value="Composite" />
<param name="DatePattern" value="yyyyMMdd/HH&quot;Charger2.log&quot;" />
<param name="maximumFileSize" value="200MB" />
<param name="MaxSizeRollBackups" value="5" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date %level %thread %logger - %message%newline" />
</layout>
</appender>
<logger name="Charger3" additivity="false">
<level value="ALL" />
<appender-ref ref="Charger3" />
</logger>
<appender name="Charger3" type="log4net.Appender.RollingFileAppender">
<param name="File" value="logs\Charger\" />
<param name="AppendToFile" value="true" />
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
<Encoding value="UTF-8" />
<param name="StaticLogFileName" value="false" />
<param name="RollingStyle" value="Composite" />
<param name="DatePattern" value="yyyyMMdd/HH&quot;Charger3.log&quot;" />
<param name="maximumFileSize" value="200MB" />
<param name="MaxSizeRollBackups" value="5" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date %level %thread %logger - %message%newline" />
</layout>
</appender>
<logger name="Charger4" additivity="false">
<level value="ALL" />
<appender-ref ref="Charger4" />
</logger>
<appender name="Charger4" type="log4net.Appender.RollingFileAppender">
<param name="File" value="logs\Charger\" />
<param name="AppendToFile" value="true" />
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
<Encoding value="UTF-8" />
<param name="StaticLogFileName" value="false" />
<param name="RollingStyle" value="Composite" />
<param name="DatePattern" value="yyyyMMdd/HH&quot;Charger4.log&quot;" />
<param name="maximumFileSize" value="200MB" />
<param name="MaxSizeRollBackups" value="5" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date %level %thread %logger - %message%newline" />
</layout>
</appender>
<logger name="Charger5" additivity="false">
<level value="ALL" />
<appender-ref ref="Charger5" />
</logger>
<appender name="Charger5" type="log4net.Appender.RollingFileAppender">
<param name="File" value="logs\Charger\" />
<param name="AppendToFile" value="true" />
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
<Encoding value="UTF-8" />
<param name="StaticLogFileName" value="false" />
<param name="RollingStyle" value="Composite" />
<param name="DatePattern" value="yyyyMMdd/HH&quot;Charger5.log&quot;" />
<param name="maximumFileSize" value="200MB" />
<param name="MaxSizeRollBackups" value="5" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date %level %thread %logger - %message%newline" />
</layout>
</appender>
<logger name="Charger6" additivity="false">
<level value="ALL" />
<appender-ref ref="Charger6" />
</logger>
<appender name="Charger6" type="log4net.Appender.RollingFileAppender">
<param name="File" value="logs\Charger\" />
<param name="AppendToFile" value="true" />
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
<Encoding value="UTF-8" />
<param name="StaticLogFileName" value="false" />
<param name="RollingStyle" value="Composite" />
<param name="DatePattern" value="yyyyMMdd/HH&quot;Charger6.log&quot;" />
<param name="maximumFileSize" value="200MB" />
<param name="MaxSizeRollBackups" value="5" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date %level %thread %logger - %message%newline" />
</layout>
</appender>
<logger name="Charger7" additivity="false">
<level value="ALL" />
<appender-ref ref="Charger7" />
</logger>
<appender name="Charger7" type="log4net.Appender.RollingFileAppender">
<param name="File" value="logs\Charger\" />
<param name="AppendToFile" value="true" />
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
<Encoding value="UTF-8" />
<param name="StaticLogFileName" value="false" />
<param name="RollingStyle" value="Composite" />
<param name="DatePattern" value="yyyyMMdd/HH&quot;Charger7.log&quot;" />
<param name="maximumFileSize" value="200MB" />
<param name="MaxSizeRollBackups" value="5" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date %level %thread %logger - %message%newline" />
</layout>
</appender>
<logger name="Charger8" additivity="false">
<level value="ALL" />
<appender-ref ref="Charger8" />
</logger>
<appender name="Charger8" type="log4net.Appender.RollingFileAppender">
<param name="File" value="logs\Charger\" />
<param name="AppendToFile" value="true" />
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
<Encoding value="UTF-8" />
<param name="StaticLogFileName" value="false" />
<param name="RollingStyle" value="Composite" />
<param name="DatePattern" value="yyyyMMdd/HH&quot;Charger8.log&quot;" />
<param name="maximumFileSize" value="200MB" />
<param name="MaxSizeRollBackups" value="5" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date %level %thread %logger - %message%newline" />
</layout>
</appender>
<root>
<level value="ALL" />
<appender-ref ref="Console" />
<appender-ref ref="RollingFile" />
</root>
</log4net>

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save