none
eventlog.exists not working for setup event log ? RRS feed

  • Question

  • Hi all,
    i am exporting event log using  ExportLogAndMessages() method but before im checking that event log is exist or not using EventLog.Exists(LogName) methods it is working fine for "Application", "Security" logs but when i am checking for "Setup" it is returing false value while checking but "Setup" log is available in machine.
    why is is retuning false?
    any other method to check events available on machine or not?
    TIA

    below is my code

    if (EventLog.Exists(LogName))
    {
    EventLogSession logsession = new EventLogSession();
    logsession.ExportLogAndMessages(LogName, PathType.LogName, "*", subfolderpath, false, CultureInfo.CurrentCulture);
    
    }

     


    sumitk

    Friday, November 24, 2017 11:27 AM

All replies

  • Hi,

    Thank you for posting here.

    According to the error message, did you check whether the log exists on the local compute?

    Did you check whether the source exists on the local computer, use SourceExists

    I suggest that you can use the administrator to run the application.  Because this method accesses the registry, you must have the appropriate registry permissions on the local computer; otherwise, the query returns false. 

    As far as I know that the name of the log method to search for. Possible values include: Application, Security, System, other application-specific logs (such as those associated with Active Directory), or any custom log on the computer.

    Maybe the setup has beyond its scope.

    Note: you can use the command to access the setup log. About more information, please see the Windows Setup Log Files and Event Logs

    Best Regards,

    Hart


    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Proposed as answer by Hart Wang Wednesday, November 29, 2017 2:22 AM
    Monday, November 27, 2017 3:16 AM
  • Hi,

    Thank you for posting here.

    According to the error message, did you check whether the log exists on the local compute?

    Did you check whether the source exists on the local computer, use SourceExists

    I suggest that you can use the administrator to run the application.  Because this method accesses the registry, you must have the appropriate registry permissions on the local computer; otherwise, the query returns false. 

    As far as I know that the name of the log method to search for. Possible values include: Application, Security, System, other application-specific logs (such as those associated with Active Directory), or any custom log on the computer.

    Maybe the setup has beyond its scope.

    Note: you can use the command to access the setup log. About more information, please see the Windows Setup Log Files and Event Logs

    Best Regards,

    Hart


    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    hi ,

    thanks for you reply.yes i checked the physical existence of "Sectup" log on my machine and it is having logs also.i also checked the  SourceExists but is also returning false for setup logs.i am running my application with administrative rights.

    one thing i want to mention that if i am not checking existence of logs with "SourceExists" or "Eventlog.Exist" means if i am exporting event without any validation it is exporting setup logs too.

    so i am not getting why validation is not working for "Setuplog"

    Thanks


    sumitk

    Wednesday, November 29, 2017 4:28 AM
  • Hi,

    >>.i also checked the  SourceExists but is also returning false for setup logs

    According to the description, The file cannot be found on local computer.

    Best Regards,

    Hart


    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, December 1, 2017 9:26 AM