code_junkie

How to use enterprise library logging in a .NET custom action

Nov 12th, 2011
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. var factory = new LogWriterFactory( new FakeConfigSource( "foo.config" ) );
  2. var field = typeof ( Logger ).GetField( "factory", BindingFlags.Static | BindingFlags.NonPublic );
  3. field.SetValue( null, factory );
  4. Logger.Write( "Test" );
  5.  
  6. Const msiMessageTypeInfo = &H04000000
  7. Const msiMessageTypeFatalExit = &H00000000
  8. Const msiMessageTypeError = &H01000000
  9. Const msiMessageTypeWarning = &H02000000
  10. Const msiMessageTypeUser = &H03000000
  11.  
  12. Dim rec : Set rec = Session.Installer.CreateRecord(1)
  13. rec.StringData(1) = "Your log message."
  14.  
  15. Session.Message msiMessageTypeInfo, rec
  16.  
  17. string installDir = System.IO.Path.GetDirectoryName(
  18. System.Reflection.Assembly.GetExecutingAssembly().Location);
  19. System.IO.File.Copy(
  20. System.IO.Path.Combine(installDir, "<Insert Assembly Name>.dll"),
  21. System.IO.Path.Combine(Environment.SystemDirectory, "<Insert Assembly Name>.dll"),
  22. true);
Add Comment
Please, Sign In to add comment