For .Net CA's there is a Log method on the session object. As for C/C+ custom 
actions, the SDK provides a WcaLog(LOGMSG_STANDARD, "Message goes here.") 
method.

Both of these will write to the Windows installer log, if it's enabled.

-----Original Message-----
From: Chad Petersen [mailto:chad.peter...@harlandfs.com] 
Sent: Thursday, March 15, 2012 5:42 PM
To: General discussion for Windows Installer XML toolset.
Subject: Re: [WiX-users] Setting MsiLogFileLocation property

I use a second custom action called WriteToMSILog that I call at specific times 
from my first custom action to log to the normal log file that everything else 
writes to. Keeps everything in one log file and is easy to call as needed.

The CDATA portion looks like this (Jscript example)

<![CDATA[
                        try
                        {
                                var szMessage = Session.Property( 
"WriteToMSILog" );
                                var msiMessageTypeInfo = 0x04000000;//  
Informative message for log, not to be displayed. 
                                var sDelim = 
"************************************************************";
                                                                 
                                //Create a record with only one field   
                                var oRecord = Session.Installer.CreateRecord( 1 
);
                        
                                //Create the full message
                                szFullMessage = sDelim + "\n" + szMessage;
                                        
                                oRecord.StringData( 0 ) = "[1]";
                                oRecord.StringData( 1 ) = szFullMessage;
                        
                                Session.FormatRecord( oRecord );
                                Session.Message( msiMessageTypeInfo, oRecord ); 
  
                                
                                oRecord = null;
                        }
                        catch(e)
                        {
                        }
                ]]>


The call from my first custom action looks like this

Session.Property("WriteToMSILog") = "Process Name: " + pProps[proc];
Session.DoAction("WriteToMSILog");

-----Original Message-----
From: Alec Swan [mailto:alecs...@gmail.com] 
Sent: Thursday, March 15, 2012 3:20 PM
To: General discussion for Windows Installer XML toolset.
Subject: Re: [WiX-users] Setting MsiLogFileLocation property

Wow, this is a pretty active mailing list. I think we have the
definite answer now.

As you can already tell I am a newbie to WIX, so please take it easy
on me with my next question. What logging mechanism do you normally
use to log messages from your custom actions?

Thanks,

Alec

On Thu, Mar 15, 2012 at 12:58 PM, Castro, Edwin G. (Hillsboro)
<edwin.cas...@fiserv.com> wrote:
> In addition, the Windows Installer engine starts producing log messages 
> before it loads the MSI package to determine what log file to use.
>
> In short, one can set a log file:
> * On the command line
> * As an argument to MsiProductInstall()
> * In the registry (global and applies to all MSI packages, cannot be changed 
> on a per package basis)
>
> The MsiLogFileLocation property is automatically set by the Windows Installer 
> engine to allow a MSI UI to display the log file location on a dialog. 
> Changing the value of MsiLogFileLocation within the MSI package itself does 
> not change where the Windows Installer engine is logging to (as evidenced by 
> the tests performed by various people).
>
> To automatically set a log file you'll need to use a bootstrapper as was 
> already suggested so that the bootstrapper can set it on the command line or 
> as an argument to MsiProductInstall().
>
> Your system administrator could use the registry approach to control whether 
> all MSI packages generate a log file to a specific folder location with a 
> random: MSI*.LOG name.
>
> This is documented in the MSDN documentation so if anybody wants to use this 
> approach I suggest they check MSDN at 
> http://msdn.microsoft.com/en-us/library/windows/desktop/aa372847.aspx
>
> Edwin G. Castro
> Software Developer - Staff
> Digital Channels
> Fiserv
> Office: 503-746-0643
> Fax: 503-617-0291
> www.fiserv.com
> Please consider the environment before printing this e-mail
>
>
>
>> -----Original Message-----
>> From: Chad Petersen [mailto:chad.peter...@harlandfs.com]
>> Sent: Thursday, March 15, 2012 11:22 AM
>> To: General discussion for Windows Installer XML toolset.
>> Subject: Re: [WiX-users] Setting MsiLogFileLocation property
>>
>> A good test anyone can try. Run a command something like this.
>>
>> MSIEXEC.EXE /L*v C:\Foobar\test.log /I <path to MSI>
>>
>> For that log folder that you point to make sure the C:\Foobar directly DOES
>> NOT EXIST.
>>
>> Note how MSIEXEC.EXE will simply error out rather than creating the Foobar
>> folder in which to create the log file.
>>
>> I feel this shows an example of what Edwin and others are talking about. Log
>> file must be established before MSIEXEC calls into the MSI.
>>
>> -----Original Message-----
>> From: Castro, Edwin G. (Hillsboro) [mailto:edwin.cas...@fiserv.com]
>> Sent: Thursday, March 15, 2012 11:10 AM
>> To: General discussion for Windows Installer XML toolset.
>> Subject: Re: [WiX-users] Setting MsiLogFileLocation property
>>
>> WiX is not in control of the MsiLogFileLocation property. This is 
>> functionality
>> provided by Windows Installer.
>>
>> As mentioned earlier, the log file location must be set before the MSI
>> package is loaded by the Windows Installer engine. This is how Windows
>> Installer works and the WiX team has no control over it.
>>
>> Please refer to http://msdn.microsoft.com/en-
>> us/library/windows/desktop/aa372847.aspx for information on Windows
>> Installer Logging. In particular check the Normal Logging  section at
>> http://msdn.microsoft.com/en-us/library/windows/desktop/aa370536.aspx
>> for an explanation of your options.
>>
>> Edwin G. Castro
>> Software Developer - Staff
>> Digital Channels
>> Fiserv
>> Office: 503-746-0643
>> Fax: 503-617-0291
>> www.fiserv.com
>> P Please consider the environment before printing this e-mail
>>
>>
>>
>> > -----Original Message-----
>> > From: Alec Swan [mailto:alecs...@gmail.com]
>> > Sent: Thursday, March 15, 2012 10:44 AM
>> > To: General discussion for Windows Installer XML toolset.
>> > Subject: Re: [WiX-users] Setting MsiLogFileLocation property
>> >
>> > Phil, thank you for sharing your experience.
>> >
>> > I would like to keep this thread active until we get a definite answer
>> > from the WIX team. Whether it is "You can't enable MSI logging in the
>> > current version of WIX but will be available in version x.x" or "This
>> > is how you do this ..." - it will still be very helpful.
>> >
>> > Thanks,
>> >
>> > Alec
>> >
>> > On Thu, Mar 15, 2012 at 11:32 AM, Wilson, Phil
>> > <phil.wil...@invensys.com>
>> > wrote:
>> > > You can't set MsiLogFileLocation, as the MSDN docs pretty much say.
>> > > You
>> > can try to set it but it's ineffective. If you set it in the property
>> > table it just gets overwritten. If you set it with a type 51 it just gets 
>> > ignored.
>> > >
>> > > Phil W
>> > >
>> > > -----Original Message-----
>> > > From: Alec Swan [mailto:alecs...@gmail.com]
>> > > Sent: Thursday, March 15, 2012 10:09 AM
>> > > To: General discussion for Windows Installer XML toolset.
>> > > Subject: Re: [WiX-users] Setting MsiLogFileLocation property
>> > >
>> > > Adam,
>> > >
>> > > This post indicates that it is possible to set MSI property from WIX:
>> > > http://blogs.technet.com/b/alexshev/archive/2009/05/16/from-msi-to-
>> > wix
>> > > -part-23-dll-custom-actions-logging-and-setting-properties.aspx
>> > >
>> > > If this is true, shouldn't I be able to use this approach to set
>> > > some kind of MSI property to force logging and/or configure location
>> > > of the log file?
>> > >
>> > > Enabling logging seems to be a pretty common question on the WIX
>> > > forum, can we have WIX team to provide a recommendation on how to
>> do
>> > > this?
>> > >
>> > > Thanks,
>> > >
>> > > Alec
>> > >
>> > > On Thu, Mar 15, 2012 at 10:54 AM, Adam Kadzban
>> > > <mightyshorta...@gmail.com> wrote:
>> > >> Alec,
>> > >>
>> > >> As far as I know, you can't set the log file location inside WIX
>> > >> because you need to tell msiexec where to write the log file to
>> > >> before actually starting the MSI.  You need some sort of
>> > >> bootstrapper that calls msiexec with the logging options. I've used
>> > >> IExpress in the past, but I think I'll be switching to dotNetInstaller 
>> > >> soon.
>> > >>
>> > >> -Adam
>> > >>
>> > >> On Thu, Mar 15, 2012 at 11:43 AM, John Cooper
>> > <jocoo...@jackhenry.com>wrote:
>> > >>
>> > >>> I've seen the same bugs CP has seen.  I've got it set in my
>> > >>> installers, but only because CD demands it.  Setting it causes a
>> > >>> fair number of install failures, particular in 
>> > >>> install/repair/uninstall cycles.
>> > >>>
>> > >>> --
>> > >>> John Merryweather Cooper
>> > >>> Build & Install Engineer - ESA
>> > >>> Jack Henry & Associates, Inc.®
>> > >>> Shawnee Mission, KS  66227
>> > >>> Office:  913-341-3434 x791011
>> > >>> jocoo...@jackhenry.com
>> > >>> www.jackhenry.com
>> > >>>
>> > >>>
>> > >>>
>> > >>>
>> > >>> -----Original Message-----
>> > >>> From: Alec Swan [mailto:alecs...@gmail.com]
>> > >>> Sent: Thursday, March 15, 2012 11:30 AM
>> > >>> To: General discussion for Windows Installer XML toolset.
>> > >>> Subject: Re: [WiX-users] Setting MsiLogFileLocation property
>> > >>>
>> > >>> The following thread implied that the file log location can be set
>> > >>> through MsiLogFileLocation property in WIX:
>> > >>>
>> > >>> http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/Msi-
>> > >>> Lo
>> > >>> gging-td707004.html#a707011
>> > >>>
>> > >>> But it sounds like Rob is saying this is not possible.
>> > >>>
>> > >>> So, how can I reliably enable MSI logging programmatically in WIX
>> > >>> code and ideally set the location of the log file? We need to
>> > >>> support Windows XP SP2 and higher.
>> > >>>
>> > >>> Thanks,
>> > >>>
>> > >>> Alec
>> > >>>
>> > >>> On Thu, Mar 15, 2012 at 10:05 AM, Christopher Painter
>> > >>> <chr...@iswix.com>
>> > >>> wrote:
>> > >>> > I don't know if this is common knowledge but I don't set the
>> > >>> > MsiLogging property anymore.  There' s a known bug in Windows 7
>> > >>> > where Explorer / Shell can lose reference to the installer log
>> > >>> > file location and it causes the installer to crash out.    It
>> > >>> > can manifest itself on uninstall  which means you are stuck
>> > >>> > unless you run the uninstall from the command line passing in an
>> explicit path.
>> > >>> >
>> > >>> > ----------------------------------------
>> > >>> >
>> > >>> > From: "Rob Mensching" <r...@robmensching.com>
>> > >>> >
>> > >>> > Sent: Thursday, March 15, 2012 11:02 AM
>> > >>> >
>> > >>> > To: "General discussion for Windows Installer XML toolset."
>> > >>> > <wix-users@lists.sourceforge.net>
>> > >>> >
>> > >>> > Subject: Re: [WiX-users] Setting MsiLogFileLocation property
>> > >>> >
>> > >>> >
>> > >>> > I don't think you can set the log file using MsiLogFileLocation.
>> > >>> > I think it
>> > >>> >
>> > >>> > *gets* set to the log file location. You can force your package
>> > >>> > to require
>> > >>> >
>> > >>> > MSI 4.0 by setting the Package/InstallerVersion attribute.
>> > >>> >
>> > >>> >
>> > >>> > On Wed, Mar 14, 2012 at 9:10 PM, Alec Swan <alecs...@gmail.com>
>> > wrote:
>> > >>> >
>> > >>> >
>> > >>> >> Hello,
>> > >>> >
>> > >>> >>
>> > >>> >
>> > >>> >> I need to enable verbose logging and configure MSI log file 
>> > >>> >> location.
>> > >>> >
>> > >>> >> I am currently doing this by adding the following properties
>> > >>> >> inside of
>> > >>> >
>> > >>> >> my .wxs file:
>> > >>> >
>> > >>> >> <Wix>
>> > >>> >
>> > >>> >> <Product>
>> > >>> >
>> > >>> >> <Property Id="LOGVERBOSE">1</Property>
>> > >>> >
>> > >>> >> <Property Id="MsiLogFileLocation">x:/WIX/wix-msi.log</Property>
>> > >>> >
>> > >>> >> ...
>> > >>> >
>> > >>> >>
>> > >>> >
>> > >>> >> Is this the right place for these properties?
>> > >>> >
>> > >>> >>
>> > >>> >
>> > >>> >> If so, then I am assuming that the reason why they are not
>> > >>> >> taking
>> > >>> >
>> > >>> >> effect is that the MSI version our Wix project is using is
>> > >>> >> lower than
>> > >>> >
>> > >>> >> 4.0 and does not support MsiLogFileLocation property. Where do
>> > >>> >> I
>> > >>> >
>> > >>> >> update the MSI version in my WIX project?
>> > >>> >
>> > >>> >>
>> > >>> >
>> > >>> >> Thanks,
>> > >>> >
>> > >>> >>
>> > >>> >
>> > >>> >> Alec
>> > >>> >
>> > >>> >>
>> > >>> >
>> > >>> >>
>> > >>> >
>> > >>> >>
>> > >>> > ----------------------------------------------------------------
>> > >>> > --
>> > >>> > ----
>> > >>> > ------
>> > >>> > --
>> > >>> >
>> > >>> >> This SF email is sponsosred by:
>> > >>> >
>> > >>> >> Try Windows Azure free for 90 days Click Here
>> > >>> >
>> > >>> >> http://p.sf.net/sfu/sfd2d-msazure
>> > >>> >
>> > >>> >> _______________________________________________
>> > >>> >
>> > >>> >> WiX-users mailing list
>> > >>> >
>> > >>> >> WiX-users@lists.sourceforge.net
>> > >>> >
>> > >>> >> https://lists.sourceforge.net/lists/listinfo/wix-users
>> > >>> >
>> > >>> >>
>> > >>> >
>> > >>> >
>> > >>> > --
>> > >>> >
>> > >>> > virtually, Rob Mensching - http://RobMensching.com LLC
>> > >>> >
>> > >>> > ----------------------------------------------------------------
>> > >>> > --
>> > >>> > ----
>> > >>> > ------
>> > >>> > --
>> > >>> >
>> > >>> > This SF email is sponsosred by:
>> > >>> >
>> > >>> > Try Windows Azure free for 90 days Click Here
>> > >>> >
>> > >>> > http://p.sf.net/sfu/sfd2d-msazure
>> > >>> >
>> > >>> > _______________________________________________
>> > >>> >
>> > >>> > WiX-users mailing list
>> > >>> >
>> > >>> > WiX-users@lists.sourceforge.net
>> > >>> >
>> > >>> > https://lists.sourceforge.net/lists/listinfo/wix-users
>> > >>> >
>> > >>> >
>> > >>> > ----------------------------------------------------------------
>> > >>> > --
>> > >>> > ----
>> > >>> > --------
>> > >>> > This SF email is sponsosred by:
>> > >>> > Try Windows Azure free for 90 days Click Here
>> > >>> > http://p.sf.net/sfu/sfd2d-msazure
>> > >>> > _______________________________________________
>> > >>> > WiX-users mailing list
>> > >>> > WiX-users@lists.sourceforge.net
>> > >>> > https://lists.sourceforge.net/lists/listinfo/wix-users
>> > >>>
>> > >>>
>> > >>> ------------------------------------------------------------------
>> > >>> --
>> > >>> ----------
>> > >>> This SF email is sponsosred by:
>> > >>> Try Windows Azure free for 90 days Click Here
>> > >>> http://p.sf.net/sfu/sfd2d-
>> > msazure___________________________________
>> > >>> ____________
>> > >>> WiX-users mailing list
>> > >>> WiX-users@lists.sourceforge.net
>> > >>> https://lists.sourceforge.net/lists/listinfo/wix-users
>> > >>> NOTICE: This electronic mail message and any files transmitted
>> > >>> with it are intended exclusively for the individual or entity to
>> > >>> which it is addressed. The message, together with any attachment,
>> > >>> may contain confidential and/or privileged information.
>> > >>> Any unauthorized review, use, printing, saving, copying,
>> > >>> disclosure or distribution is strictly prohibited. If you have
>> > >>> received this message in error, please immediately advise the
>> > >>> sender by reply email and delete all copies.
>> > >>>
>> > >>>
>> > >>>
>> > >>> ------------------------------------------------------------------
>> > >>> --
>> > >>> ----------
>> > >>> This SF email is sponsosred by:
>> > >>> Try Windows Azure free for 90 days Click Here
>> > >>> http://p.sf.net/sfu/sfd2d-msazure
>> > >>> _______________________________________________
>> > >>> WiX-users mailing list
>> > >>> WiX-users@lists.sourceforge.net
>> > >>> https://lists.sourceforge.net/lists/listinfo/wix-users
>> > >>>
>> > >> -------------------------------------------------------------------
>> > >> --
>> > >> ---------
>> > >> This SF email is sponsosred by:
>> > >> Try Windows Azure free for 90 days Click Here
>> > >> http://p.sf.net/sfu/sfd2d-msazure
>> > >> _______________________________________________
>> > >> WiX-users mailing list
>> > >> WiX-users@lists.sourceforge.net
>> > >> https://lists.sourceforge.net/lists/listinfo/wix-users
>> > >
>> > > --------------------------------------------------------------------
>> > > --
>> > > --------
>> > > This SF email is sponsosred by:
>> > > Try Windows Azure free for 90 days Click Here
>> > > http://p.sf.net/sfu/sfd2d-msazure
>> > > _______________________________________________
>> > > WiX-users mailing list
>> > > WiX-users@lists.sourceforge.net
>> > > https://lists.sourceforge.net/lists/listinfo/wix-users
>> > >
>> > >
>> > > *** Confidentiality Notice: This e-mail, including any associated or
>> > > attached
>> > files, is intended solely for the individual or entity to which it is 
>> > addressed.
>> > This e-mail is confidential and may well also be legally privileged.
>> > If you have received it in error, you are on notice of its status.
>> > Please notify the sender immediately by reply e-mail and then delete this
>> message from your system.
>> > Please do not copy it or use it for any purposes, or disclose its
>> > contents to any other person. This email comes from a division of the
>> > Invensys Group, owned by Invensys plc, which is a company registered
>> > in England and Wales with its registered office at 3rd Floor, 40
>> > Grosvenor Place, London, SW1X 7AW (Registered number 166023). For a
>> > list of European legal entities within the Invensys Group, please go
>> > to http://www.invensys.com/en/legal/default.aspx.
>> > >
>> > > You may contact Invensys plc on +44 (0)20 3155 1200 or e-mail
>> > recept...@invensys.com. This e-mail and any attachments thereto may be
>> > subject to the terms of any agreements between Invensys (and/or its
>> > subsidiaries and affiliates) and the recipient (and/or its
>> > subsidiaries and affiliates).
>> > >
>> > >
>> > >
>> > > --------------------------------------------------------------------
>> > > --
>> > > --------
>> > > This SF email is sponsosred by:
>> > > Try Windows Azure free for 90 days Click Here
>> > > http://p.sf.net/sfu/sfd2d-msazure
>> > > _______________________________________________
>> > > WiX-users mailing list
>> > > WiX-users@lists.sourceforge.net
>> > > https://lists.sourceforge.net/lists/listinfo/wix-users
>> >
>> > ----------------------------------------------------------------------
>> > --------
>> > This SF email is sponsosred by:
>> > Try Windows Azure free for 90 days Click Here
>> > http://p.sf.net/sfu/sfd2d- msazure
>> > _______________________________________________
>> > WiX-users mailing list
>> > WiX-users@lists.sourceforge.net
>> > https://lists.sourceforge.net/lists/listinfo/wix-users
>> ------------------------------------------------------------------------------
>> This SF email is sponsosred by:
>> Try Windows Azure free for 90 days Click Here http://p.sf.net/sfu/sfd2d-
>> msazure _______________________________________________
>> WiX-users mailing list
>> WiX-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/wix-users
>> ------------------------------------------------------------------------------
>> This SF email is sponsosred by:
>> Try Windows Azure free for 90 days Click Here http://p.sf.net/sfu/sfd2d-
>> msazure _______________________________________________
>> WiX-users mailing list
>> WiX-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/wix-users
> ------------------------------------------------------------------------------
> This SF email is sponsosred by:
> Try Windows Azure free for 90 days Click Here
> http://p.sf.net/sfu/sfd2d-msazure
> _______________________________________________
> WiX-users mailing list
> WiX-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/wix-users

------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users
------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users
------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users

Reply via email to