-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: How to write only custom messages in log file.
PostPosted: Sat May 03, 2008 5:49 am 
Newbie

Joined: Sat May 03, 2008 1:57 am
Posts: 3
Location: Nagpur, India
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:
1.2.40000
Mapping documents:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="NHibernateApplication2.Person, NHibernateApplication2" table="Person" lazy="false">
<id name="PersonId" column="personid" type="integer">
<generator class="assigned" />
</id>
<property name="PersonName" column="name" type="string"/>
<property name="JobTitle" column="jobtitle" type="string"/>
<property name="FrequentFlyer" column="frequentflyer" type="integer"/>
<property name="LastUpdate" column="lastupdated" type="timestamp"/>
</class>
</hibernate-mapping>

Code between sessionFactory.openSession() and session.close():
logger.Info("Accessing all Persons");

try
{
ArrayList allPersons = new ArrayList();
IEnumerable enumerable = session.CreateQuery("FROM Person").Enumerable();
IEnumerator enumerator = enumerable.GetEnumerator();
while(enumerator.MoveNext())
{
Person fetchPerson = enumerator.Current as Person;
if(fetchPerson != null)
{
cmbPersonNames.Items.Add(fetchPerson);
}
}
cmbPersonNames.SelectedIndex = 0;
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
//logger.Error(ex.Message, ex);
MessageBox.Show(ex.Message);
}
finally
{
session.Close();
}
Full stack trace of any exception that occurs:

Name and version of the database you are using:
PostgreSQL, travel_db

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


How to Write only custome messages to log file not all the messages generated by NHibernate session?

Read this: http://hibernate.org/42.html


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 05, 2008 6:53 am 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
You can enable/disable logging for NHibernate on namespace level:

Code:
    <logger name="NHibernate">
      <level value="OFF" />
    </logger>

    <logger name="NHibernate.Cfg">
      <level value="INFO" />
    </logger>

    <logger name="NHibernate.Xyz">
      <level value="DEBUG" />
    </logger>


Have a look at the log4net docs if you need more info.

_________________
--Wolfgang


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.