diff --git a/(Setup) Log 4 Graylog/(Setup) Log 4 Graylog.vdproj b/(Setup) Log 4 Graylog/(Setup) Log 4 Graylog.vdproj index adc18ed..f310dea 100644 --- a/(Setup) Log 4 Graylog/(Setup) Log 4 Graylog.vdproj +++ b/(Setup) Log 4 Graylog/(Setup) Log 4 Graylog.vdproj @@ -21,10 +21,22 @@ } "Entry" { - "MsmKey" = "8:_4F69E6F677D2494E9E867224E3551233" + "MsmKey" = "8:_8F56FA697AF246D1984287C0CF6F963D" "OwnerKey" = "8:_UNDEFINED" "MsmSig" = "8:_UNDEFINED" } + "Entry" + { + "MsmKey" = "8:_DBAC22F7925D4A24B0D64C4D570A4B6F" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_UNDEFINED" + "OwnerKey" = "8:_DBAC22F7925D4A24B0D64C4D570A4B6F" + "MsmSig" = "8:_UNDEFINED" + } } "Configurations" { @@ -97,6 +109,62 @@ { "CustomAction" { + "{4AA51A2D-7D85-4A59-BA75-B0809FC8B380}:_0843631901554DAC83709FFCF1649025" + { + "Name" = "8:serviceInstaller.dll" + "Condition" = "8:" + "Object" = "8:_DBAC22F7925D4A24B0D64C4D570A4B6F" + "FileType" = "3:1" + "InstallAction" = "3:3" + "Arguments" = "8:" + "EntryPoint" = "8:" + "Sequence" = "3:1" + "Identifier" = "8:_C744F9D4_F4BB_4DCA_B07E_97AD95BCF80F" + "InstallerClass" = "11:TRUE" + "CustomActionData" = "8:" + } + "{4AA51A2D-7D85-4A59-BA75-B0809FC8B380}:_0B3A29897E854DEFB7A6A4452928C16F" + { + "Name" = "8:serviceInstaller.dll" + "Condition" = "8:" + "Object" = "8:_DBAC22F7925D4A24B0D64C4D570A4B6F" + "FileType" = "3:1" + "InstallAction" = "3:1" + "Arguments" = "8:" + "EntryPoint" = "8:" + "Sequence" = "3:1" + "Identifier" = "8:_C19353EA_6BF6_4096_96A2_E4E3AEBAFED4" + "InstallerClass" = "11:TRUE" + "CustomActionData" = "8:" + } + "{4AA51A2D-7D85-4A59-BA75-B0809FC8B380}:_A67595795DDE4586B20445A58C366A4D" + { + "Name" = "8:serviceInstaller.dll" + "Condition" = "8:" + "Object" = "8:_DBAC22F7925D4A24B0D64C4D570A4B6F" + "FileType" = "3:1" + "InstallAction" = "3:2" + "Arguments" = "8:" + "EntryPoint" = "8:" + "Sequence" = "3:1" + "Identifier" = "8:_7FB0B943_18FC_4169_977C_FB0E26458945" + "InstallerClass" = "11:TRUE" + "CustomActionData" = "8:" + } + "{4AA51A2D-7D85-4A59-BA75-B0809FC8B380}:_EA6E62AD519E4C989C26EED7A86F1990" + { + "Name" = "8:serviceInstaller.dll" + "Condition" = "8:" + "Object" = "8:_DBAC22F7925D4A24B0D64C4D570A4B6F" + "FileType" = "3:1" + "InstallAction" = "3:4" + "Arguments" = "8:" + "EntryPoint" = "8:" + "Sequence" = "3:1" + "Identifier" = "8:_E99DE823_7220_4E56_BD53_383C00AB00E2" + "InstallerClass" = "11:TRUE" + "CustomActionData" = "8:" + } } "DefaultFeature" { @@ -118,14 +186,53 @@ "Architecture" = "2:0" "Runtime" = "2:0" } + "{A06ECF26-33A3-4562-8140-9B0E340D4F24}:_3A525A75C262405F97EE6EAD26B5B0EA" + { + "Name" = "8:.NET Framework" + "Message" = "8:[VSDNETMSG]" + "FrameworkVersion" = "8:.NETFramework,Version=v4.7.2" + "AllowLaterVersions" = "11:FALSE" + "InstallUrl" = "8:http://go.microsoft.com/fwlink/?LinkId=863262" + } } } "File" { - "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_4F69E6F677D2494E9E867224E3551233" + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_8F56FA697AF246D1984287C0CF6F963D" { - "SourcePath" = "8:..\\console_log4graylog\\Log_4_Graylog.ico" - "TargetName" = "8:Log_4_Graylog.ico" + "SourcePath" = "8:..\\console_log4graylog\\Resource\\Log4Graylog.ico" + "TargetName" = "8:Log4Graylog.ico" + "Tag" = "8:" + "Folder" = "8:_9B600ABCFF494174A956D068E6CF1046" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:TRUE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{9F6F8455-1EF1-4B85-886A-4223BCC8E7F7}:_DBAC22F7925D4A24B0D64C4D570A4B6F" + { + "AssemblyRegister" = "3:1" + "AssemblyIsInGAC" = "11:FALSE" + "AssemblyAsmDisplayName" = "8:serviceInstaller, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL" + "ScatterAssemblies" + { + "_DBAC22F7925D4A24B0D64C4D570A4B6F" + { + "Name" = "8:serviceInstaller.dll" + "Attributes" = "3:512" + } + } + "SourcePath" = "8:..\\serviceInstaller\\bin\\Release\\serviceInstaller.dll" + "TargetName" = "8:" "Tag" = "8:" "Folder" = "8:_9B600ABCFF494174A956D068E6CF1046" "Condition" = "8:" @@ -198,15 +305,15 @@ { "Name" = "8:Microsoft Visual Studio" "ProductName" = "8:Log 4 Graylog" - "ProductCode" = "8:{E73F35BF-F750-4609-A786-958CE5C83DE7}" - "PackageCode" = "8:{558BC65A-00BF-4BBE-A6DC-C9AB352A4690}" + "ProductCode" = "8:{D843EA28-6AD4-4B10-9BA6-8878E0C1E174}" + "PackageCode" = "8:{40BF9EDE-7902-4C62-B536-E0C13CC890EF}" "UpgradeCode" = "8:{7CE09C91-3C26-4C8E-BC66-003536E12481}" "AspNetVersion" = "8:4.0.30319.0" "RestartWWWService" = "11:FALSE" "RemovePreviousVersions" = "11:TRUE" "DetectNewerInstalledVersion" = "11:TRUE" "InstallAllUsers" = "11:TRUE" - "ProductVersion" = "8:1.0.2" + "ProductVersion" = "8:1.0.3" "Manufacturer" = "8:PAL s.r.l." "ARPHELPTELEPHONE" = "8:" "ARPHELPLINK" = "8:" @@ -216,7 +323,7 @@ "Keywords" = "8:" "ARPCOMMENTS" = "8:" "ARPURLINFOABOUT" = "8:https://www.imalpal.com/en/" - "ARPPRODUCTICON" = "8:_4F69E6F677D2494E9E867224E3551233" + "ARPPRODUCTICON" = "8:_8F56FA697AF246D1984287C0CF6F963D" "ARPIconIndex" = "3:0" "SearchPath" = "8:" "UseSystemSearchPath" = "11:TRUE" @@ -319,34 +426,6 @@ } "Shortcut" { - "{970C0BB2-C7D0-45D7-ABFA-7EC378858BC0}:_0AC95449D7BB49C294086916871E955F" - { - "Name" = "8:Log 4 Graylog" - "Arguments" = "8:" - "Description" = "8:" - "ShowCmd" = "3:1" - "IconIndex" = "3:0" - "Transitive" = "11:FALSE" - "Target" = "8:_485C7AAA71924496B4CCA8F2B60EB371" - "Folder" = "8:_5CBF406C9E44415E87BBF1E35E297CB9" - "WorkingFolder" = "8:_9B600ABCFF494174A956D068E6CF1046" - "Icon" = "8:_4F69E6F677D2494E9E867224E3551233" - "Feature" = "8:" - } - "{970C0BB2-C7D0-45D7-ABFA-7EC378858BC0}:_7D574C8D097B44558FBEBD9AF12F9D46" - { - "Name" = "8:Log 4 Graylog" - "Arguments" = "8:" - "Description" = "8:" - "ShowCmd" = "3:1" - "IconIndex" = "3:0" - "Transitive" = "11:FALSE" - "Target" = "8:_485C7AAA71924496B4CCA8F2B60EB371" - "Folder" = "8:_1D6B671D343A4228A354CA138B3705BD" - "WorkingFolder" = "8:_9B600ABCFF494174A956D068E6CF1046" - "Icon" = "8:_4F69E6F677D2494E9E867224E3551233" - "Feature" = "8:" - } } "UserInterface" { diff --git a/console_log4graylog.sln b/console_log4graylog.sln index 75c6617..6c80a76 100644 --- a/console_log4graylog.sln +++ b/console_log4graylog.sln @@ -7,6 +7,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "console_log4graylog", "cons EndProject Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "(Setup) Log 4 Graylog", "(Setup) Log 4 Graylog\(Setup) Log 4 Graylog.vdproj", "{088E2DEB-3D70-42CA-A954-A81894611502}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "serviceInstaller", "serviceInstaller\serviceInstaller.csproj", "{2640AD9B-527F-49F4-B140-62CDFD6BE532}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -19,6 +21,10 @@ Global {D97CC845-BBC9-4683-9C99-C44050F3AD8B}.Release|Any CPU.Build.0 = Release|Any CPU {088E2DEB-3D70-42CA-A954-A81894611502}.Debug|Any CPU.ActiveCfg = Debug {088E2DEB-3D70-42CA-A954-A81894611502}.Release|Any CPU.ActiveCfg = Release + {2640AD9B-527F-49F4-B140-62CDFD6BE532}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2640AD9B-527F-49F4-B140-62CDFD6BE532}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2640AD9B-527F-49F4-B140-62CDFD6BE532}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2640AD9B-527F-49F4-B140-62CDFD6BE532}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/console_log4graylog/README.md b/console_log4graylog/README.md index 9fef0cb..5deb8cf 100644 --- a/console_log4graylog/README.md +++ b/console_log4graylog/README.md @@ -1,11 +1,11 @@ -# Log4Graylog +# Log4Graylog ![DotNet](https://img.shields.io/badge/Code-.NET%209.0-purple?style=flat-square&logo=dotnet) ![Graylog](https://img.shields.io/badge/Device-Graylog-red?style=flat-square&logo=graylog) ![Release](https://img.shields.io/badge/Release-v1.0.2-green?style=flat-square) -Service for monitoring and sending log files to Graylog +Service for monitoring and sending log files to Graylog. ## AppSettings @@ -78,15 +78,4 @@ Path to the folder where the file to be monitored is located } } ``` - - -## Run as Services - -**Powershell** -``` -New-Service -Name "Log4Graylog" ` - -BinaryPathName "C:\Program Files\PAL s.r.l\Log 4 Graylog\console_log4graylog.exe" ` - -DisplayName "Log 4 Graylog" ` - -Description "Servizio per il monitoring ed invio dei file di log a Graylog" ` - -StartupType Automatic -``` \ No newline at end of file + \ No newline at end of file diff --git a/console_log4graylog/Log_4_Graylog.ico b/console_log4graylog/Resource/Log4Graylog.ico similarity index 100% rename from console_log4graylog/Log_4_Graylog.ico rename to console_log4graylog/Resource/Log4Graylog.ico diff --git a/console_log4graylog/console_log4graylog.csproj b/console_log4graylog/console_log4graylog.csproj index 5f45bd9..2a61408 100644 --- a/console_log4graylog/console_log4graylog.csproj +++ b/console_log4graylog/console_log4graylog.csproj @@ -5,7 +5,7 @@ net9.0 enable enable - Log_4_Graylog.ico + Resource\Log4Graylog.ico critical @@ -18,7 +18,7 @@ - + Always diff --git a/serviceInstaller/ProjectInstaller.cs b/serviceInstaller/ProjectInstaller.cs new file mode 100644 index 0000000..7df7c5e --- /dev/null +++ b/serviceInstaller/ProjectInstaller.cs @@ -0,0 +1,51 @@ +using System.ComponentModel; +using System.Configuration.Install; +using System.Diagnostics; +using System.IO; +using System.ServiceProcess; + +namespace serviceInstaller +{ + [RunInstaller(true)] + public class ProjectInstaller : Installer + { + private ServiceProcessInstaller processInstaller; + private ServiceInstaller serviceInstaller; + + public ProjectInstaller() + { + processInstaller = new ServiceProcessInstaller + { + Account = ServiceAccount.LocalSystem + }; + + serviceInstaller = new ServiceInstaller + { + ServiceName = "Log4GraylogService", + DisplayName = "Log 4 Graylog Service", + Description = "Service for monitoring and sending log files to Graylog", + StartType = ServiceStartMode.Automatic + }; + + Installers.Add(processInstaller); + Installers.Add(serviceInstaller); + } + + public override void Install(System.Collections.IDictionary stateSaver) + { + base.Install(stateSaver); + + string assemblyPath = Context.Parameters["assemblypath"]; + string exePath = Path.Combine(Path.GetDirectoryName(assemblyPath), "console_log4graylog.exe"); + + using (ServiceController sc = new ServiceController(serviceInstaller.ServiceName)) + { + if (sc.Status == ServiceControllerStatus.Stopped) + { + Process.Start("sc", $"config \"{serviceInstaller.ServiceName}\" binPath= \"{exePath}\""); + Process.Start("sc", $"start \"{serviceInstaller.ServiceName}\""); + } + } + } + } +} \ No newline at end of file diff --git a/serviceInstaller/Properties/AssemblyInfo.cs b/serviceInstaller/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..20bf1f9 --- /dev/null +++ b/serviceInstaller/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Le informazioni generali relative a un assembly sono controllate dal seguente +// set di attributi. Modificare i valori di questi attributi per modificare le informazioni +// associate a un assembly. +[assembly: AssemblyTitle("serviceInstaller")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("serviceInstaller")] +[assembly: AssemblyCopyright("Copyright © 2025")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Se si imposta ComVisible su false, i tipi in questo assembly non saranno visibili +// ai componenti COM. Se è necessario accedere a un tipo in questo assembly da +// COM, impostare su true l'attributo ComVisible per tale tipo. +[assembly: ComVisible(false)] + +// Se il progetto viene esposto a COM, il GUID seguente verrà utilizzato come ID della libreria dei tipi +[assembly: Guid("2640ad9b-527f-49f4-b140-62cdfd6be532")] + +// Le informazioni sulla versione di un assembly sono costituite dai seguenti quattro valori: +// +// Versione principale +// Versione secondaria +// Numero di build +// Revisione +// +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/serviceInstaller/serviceInstaller.csproj b/serviceInstaller/serviceInstaller.csproj new file mode 100644 index 0000000..928d2de --- /dev/null +++ b/serviceInstaller/serviceInstaller.csproj @@ -0,0 +1,52 @@ + + + + + Debug + AnyCPU + {2640AD9B-527F-49F4-B140-62CDFD6BE532} + Library + Properties + serviceInstaller + serviceInstaller + v4.8 + 512 + true + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + Component + + + + + \ No newline at end of file