Avatar billede stefan Nybegynder
26. oktober 2000 - 08:25 Der er 13 kommentarer og
1 løsning

skrive til eventlog

Hvordan skriver jeg til min eventlog ?

Ved at skrive følgende sker der intet:
App.LogEvent \"test\", 1

Skal man angive noget først eller .... ?
Avatar billede tdaugaard Nybegynder
26. oktober 2000 - 08:33 #1
Kører du Win9x ell. Win2K/NT ?
Avatar billede stefan Nybegynder
26. oktober 2000 - 08:33 #2
win2k
Avatar billede tdaugaard Nybegynder
26. oktober 2000 - 08:35 #3
Og den skriver ikke i Error log\'en ?

Der er ikke noget at gøre så .. jeg har lige checket MSDN Library og en siger at på NT vil der blive skrevet til log systemet, på Win9x til en log fil defineret et eller andet sted ..
Avatar billede stefan Nybegynder
26. oktober 2000 - 08:37 #4
Vil det sige at det ikke er muligt at skrive til logfilen hvis man bruger win2k ??
Avatar billede tdaugaard Nybegynder
26. oktober 2000 - 08:38 #5
Nej .. Win2K går under NT .. det er pga. mit MSDN er fra \'98 ... der var Win2K af gode grunde jo ikke udkommet ;)
Avatar billede stefan Nybegynder
26. oktober 2000 - 08:44 #6
i mit MSDN står der følgende:
Logs an event in the application\'s log target. On Windows NT platforms, the method writes to the NT Event log. On Windows 95/98 platforms, the method writes to the file specified in the LogPath property; by default, if no file is specified, events will be written to a file named vbevents.log.

Nu har jeg søgt efter vbevents.log men den fil findes ikke... ????
HVORFOR kan man ikke skrive til eventlogen ??
det er noget Pi.
Avatar billede tdaugaard Nybegynder
26. oktober 2000 - 08:48 #7
\"On Windows 95/98 platforms, the method writes to the file specified in the LogPath property; by default, if no file is specified, events will be written to a file named vbevents.log.\"

\"vbevents.log\" vil altså kun eksistere hvis du kører Win9x. Ikke Win2K/NT

Har du checket samtlige log filer igennem i 2K ? Der er vist 3 mener jeg ..  (eller er det mig der tager fejl ?)
Avatar billede cstern Nybegynder
26. oktober 2000 - 09:00 #8
Jeg kopierer fra MSDN Oct 2000:
(måske skal du se på LogPath..)

INFO: Event Logging in Visual Basic

--------------------------------------------------------------------------------
The information in this article applies to:

Microsoft Visual Basic Learning, Professional, and Enterprise Editions for Windows, version 6.0
Microsoft Visual Basic Control Creation, Learning, Professional, and Enterprise Editions for Windows, version 5.0

--------------------------------------------------------------------------------


SUMMARY
The App object in Visual Basic has the following methods and properties that facilitate the creation of event logs:


  Methods: LogEvent,
            StartLogging.

  Properties: AppMode,
              AppPath.
This article addresses some of the common issues associated with these properties and methods and provides an event logging example that demonstrates their use.



MORE INFORMATION

Common Issues Regarding Event Logging
Event logging does not work within the Visual Basic IDE. To enable event logging, you must compile and run a Visual Basic project as an executable.


The LogPath and LogMode properties are read-only. The documentation in books online is incorrect in suggesting that they can be used as L-Values.


You can specify the LogPath and LogMode by using the logTarget and logMode parameters of the StartLogging method respectively.


If LogPath is not specified, the logged entries go to the event log on Windows NT and the VBEvents.log file in the %SystemRoot% directory on Windows 95 and Windows 98.


The Source in the Windows NT Event Viewer for all entries of any Visual Basic application is \"VBRuntime.\" This is by design.


Event Logging Example
Create a new a Standard EXE project (Project1) in Visual Basic (Form1 is created by default).


Add two Command buttons to Form1.


Add the following code to Form1\'s code window:



  \'=========================== CODE FOR FORM1 ==========================

      Private Sub Command1_Click()
        \'Default logging without specifying LogPath or LogMode.
        With App
            .LogEvent \"Default Logging \" & Now, vbLogEventTypeInformation
            .LogEvent .LogPath
            .LogEvent .LogMode
        End With
      End Sub

      Private Sub Command2_Click()
        \'Logging to a file by specifying LogPath and LogMode
        \'in the StartLogging method call.
        With App
            .StartLogging \"c:\\temp\\logtest.log\", 2
            \'LogMode = 2 should be the same as vbLogToFile,
            \'but vbLogToFile constant is not defined as shown
            \'in books online.
            .LogEvent \"Specified Path File Logging \" & Now,
              vbLogEventTypeInformation
            .LogEvent .LogPath
            .LogEvent .LogMode
        End With
      End Sub

      Private Sub Form_Load()
        Command1.Caption = \"Default Logging\"
        Command2.Caption = \"Specified Path\"
      End Sub
  \'======================== END OF CODE FOR FORM1 =======================
Compile the project. Run the resulting Executable file, and press the command buttons to generate the logs.


Check the logs. If you are using Windows 2000 or Windows NT, check the default logging with the Event Viewer by selecting Application from the Log menu, then press the F5 key to refresh. If you are using Windows 95 or Windows 98, you can find VBEvents.log in the %SystemRoot% directory on Windows 95 and Windows 98, typically the C:\\Win95 or C:\\Windows directory. The non-default log file (LogTest.log) for both platforms should be in the \"C:\\Temp\" directory.



Additional query words: LogPath LogMode StartLogging LogEvent

Keywords : kbnokeyword kbVBp kbVBp500 kbVBp600 kbGrpVB kbDSupport
Version : WINDOWS:5.0,6.0
Platform : WINDOWS
Issue type : kbinfo
Technology :


Last Reviewed: April 20, 2000
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.




--------------------------------------------------------------------------------
Avatar billede stefan Nybegynder
26. oktober 2000 - 10:13 #9
cstern-> det hjælper mig desvære ikke ... der sker ikke noget som helst.

tdaugaard-> yep jeg har tjecket alle 3 log filer.. der sker ikke noget som helst

Men jeg har lige læst følgende artikel:
http://support.microsoft.com/support/kb/articles/Q251/2/64.ASP
I artiklen skriver MS at man ikke kan skrive til eventlogen, i win2k,  med mindre man går ind og retter i registrerings databasen....

Jeg har endnu ikke testet om det virker
Avatar billede cstern Nybegynder
26. oktober 2000 - 10:19 #10
OK. Du har chekket i C:\\Temp efter logtest.log hvis du har kørt eksemplet?
Avatar billede cstern Nybegynder
26. oktober 2000 - 10:21 #11
Guess what: Der sker heller ikke noget under w98 med ovenstående eksempel...
Avatar billede cstern Nybegynder
26. oktober 2000 - 10:23 #12
Got it now: Du skal compile til en EXE fil først - det virker ikke i IDE

Avatar billede cstern Nybegynder
26. oktober 2000 - 10:27 #13
KB artiklen referer til ASP programmer, dvs de køres ikke af en logged in user. Det skulle ikke være nødvendigt at ændre registreringsdatabasen hvis du kører et selvstændigt program, så vidt jeg kan se. Jeg har ikke adgang til w2k her så jeg kan ikke chekke.
Avatar billede stefan Nybegynder
26. oktober 2000 - 11:52 #14
cstern ->  at compile til exe er løsningen.
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester

Seneste spørgsmål Seneste aktivitet
I går 21:00 Libre Office Impress Af Frank i Andre styresystemer
I går 11:47 VB script Af Jenshentze i Word
I går 11:21 Popup ved opstart Af mort1 i Windows
04/0918:50 Slet lokal konto Af ErikHg i Windows
04/0916:05 Ændre tal i en celle Af xvid i Excel