[jira] [Commented] (LOG4J2-1795) LogEvent serialization deserialization

2017-01-20 Thread Remko Popma (JIRA)

[ 
https://issues.apache.org/jira/browse/LOG4J2-1795?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15832602#comment-15832602
 ] 

Remko Popma commented on LOG4J2-1795:
-

We can use a similar approach as with 
[SortedArrayStringMap|https://github.com/apache/logging-log4j2/blob/master/log4j-api/src/main/java/org/apache/logging/log4j/util/SortedArrayStringMap.java],
 so we serialize where possible and drop the rest. Wrapping in MarshalledObject 
to handle NoClassDefErrors. 
But there needs to be a request. 

> LogEvent serialization deserialization
> --
>
> Key: LOG4J2-1795
> URL: https://issues.apache.org/jira/browse/LOG4J2-1795
> Project: Log4j 2
>  Issue Type: Bug
>  Components: Appenders
>Affects Versions: 2.7
>Reporter: Alexandru Ionita
>  Labels: serializable
>
> Deserialization of a LogEvent that has been serialized with the 
> Log4jLogEvent.serialize method fails after the serialized object went through 
> a byte stream.
> Here is a test that demonstrates the issue:
> https://github.com/nucatus/LogEventSerializationPOC



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

-
To unsubscribe, e-mail: log4j-dev-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-dev-h...@logging.apache.org



[jira] [Commented] (LOG4J2-1795) LogEvent serialization deserialization

2017-01-20 Thread Ralph Goers (JIRA)

[ 
https://issues.apache.org/jira/browse/LOG4J2-1795?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15832174#comment-15832174
 ] 

Ralph Goers commented on LOG4J2-1795:
-

I suspect that Jira issue would be closed as "won't fix".  The parameters are 
not included because that would mean only objects that implement Serializable 
could be included in ParameterizedMessages. 

> LogEvent serialization deserialization
> --
>
> Key: LOG4J2-1795
> URL: https://issues.apache.org/jira/browse/LOG4J2-1795
> Project: Log4j 2
>  Issue Type: Bug
>  Components: Appenders
>Affects Versions: 2.7
>Reporter: Alexandru Ionita
>  Labels: serializable
>
> Deserialization of a LogEvent that has been serialized with the 
> Log4jLogEvent.serialize method fails after the serialized object went through 
> a byte stream.
> Here is a test that demonstrates the issue:
> https://github.com/nucatus/LogEventSerializationPOC



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

-
To unsubscribe, e-mail: log4j-dev-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-dev-h...@logging.apache.org



[jira] [Commented] (LOG4J2-1795) LogEvent serialization deserialization

2017-01-20 Thread Remko Popma (JIRA)

[ 
https://issues.apache.org/jira/browse/LOG4J2-1795?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15831919#comment-15831919
 ] 

Remko Popma commented on LOG4J2-1795:
-

I agree this is counterintuitive. Do you have suggestions for improvement? We 
could improve the manual for example. Suggestions for which page and wording 
would be welcome. 

As for ParameterizedMessage serialization, would you mind raising a separate 
JIRA ticket for that? 

> LogEvent serialization deserialization
> --
>
> Key: LOG4J2-1795
> URL: https://issues.apache.org/jira/browse/LOG4J2-1795
> Project: Log4j 2
>  Issue Type: Bug
>  Components: Appenders
>Affects Versions: 2.7
>Reporter: Alexandru Ionita
>  Labels: serializable
>
> Deserialization of a LogEvent that has been serialized with the 
> Log4jLogEvent.serialize method fails after the serialized object went through 
> a byte stream.
> Here is a test that demonstrates the issue:
> https://github.com/nucatus/LogEventSerializationPOC



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

-
To unsubscribe, e-mail: log4j-dev-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-dev-h...@logging.apache.org



[jira] [Commented] (LOG4J2-1795) LogEvent serialization deserialization

2017-01-20 Thread Alexandru Ionita (JIRA)

[ 
https://issues.apache.org/jira/browse/LOG4J2-1795?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15831783#comment-15831783
 ] 

Alexandru Ionita commented on LOG4J2-1795:
--

Well, I see your point now and, indeed, the procedure is quite 
counter-intuitive. 

Regarding the {{ParameterizedMessage}}'s parameters, I think it is wrong to 
make those transient, since they are somehow aggregated with the message and 
the message will make no sense if the parameters are missing. The LogEvent is 
useless at the other end in that case, since those parameters carry the 
intrinsic value of the log message, don't you think?

> LogEvent serialization deserialization
> --
>
> Key: LOG4J2-1795
> URL: https://issues.apache.org/jira/browse/LOG4J2-1795
> Project: Log4j 2
>  Issue Type: Bug
>  Components: Appenders
>Affects Versions: 2.7
>Reporter: Alexandru Ionita
>  Labels: serializable
>
> Deserialization of a LogEvent that has been serialized with the 
> Log4jLogEvent.serialize method fails after the serialized object went through 
> a byte stream.
> Here is a test that demonstrates the issue:
> https://github.com/nucatus/LogEventSerializationPOC



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

-
To unsubscribe, e-mail: log4j-dev-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-dev-h...@logging.apache.org



[jira] [Commented] (LOG4J2-1795) LogEvent serialization deserialization

2017-01-20 Thread Remko Popma (JIRA)

[ 
https://issues.apache.org/jira/browse/LOG4J2-1795?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15831497#comment-15831497
 ] 

Remko Popma commented on LOG4J2-1795:
-

*LogEvent deserialization behaviour*

The reason that the test program fails is because of some counter-intuitive 
asymmetrical behaviour in how LogEvents are serialized and deserialized:
* to serialize a LogEvent you first convert it to a 
Log4jLogEvent$LogEventProxy, and serialize _that_ instead.
* however, Log4jLogEvent$LogEventProxy has a {{readResolve}} method that 
returns a _Log4jLogEvent_. This is not symmetrical! Deserializing a serialized 
Log4jLogEvent$LogEventProxy will give you a Log4jLogEvent.

ObjectInputStream::readObject will return the LogEvent you are looking for. 
Please use this object instead.

{code}
@Test
public void testSerialisationsDeserialization_fails() throws IOException, 
ClassNotFoundException {
// step 1: convert the LogEvent into a Log4jLogEvent$LogEventProxy instance 
(which can be serialized)
Serializable ser = Log4jLogEvent.serialize(event, true);

// step 2: serialize the Log4jLogEvent$LogEventProxy instance to a byte[] 
array
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(ser);
byte[] bytes = baos.toByteArray();

// step 3: prepare to deserialize
ObjectInputStream ois = new ObjectInputStream(new 
ByteArrayInputStream(bytes));

// step 4: deserialize the byte[] array: this returns a Log4jLogEvent 
instance!
//This is *not* a Log4jLogEvent$LogEventProxy instance!
Serializable result = (Serializable) ois.readObject(); // use this object

// step 5: this fails because the ::deserialize method *only* accepts 
Log4jLogEvent$LogEventProxy instances
Log4jLogEvent.deserialize(result);
}
{code}

*ParameterizedMessage*
As I noted in a previous comment, in ParameterizedMessage the formatted message 
is preserved correctly, but the array of parameter Objects is transient so 
message parameters will not survive serialization. This can be enhanced. Do you 
need this?

> LogEvent serialization deserialization
> --
>
> Key: LOG4J2-1795
> URL: https://issues.apache.org/jira/browse/LOG4J2-1795
> Project: Log4j 2
>  Issue Type: Bug
>  Components: Appenders
>Affects Versions: 2.7
>Reporter: Alexandru Ionita
>  Labels: serializable
>
> Deserialization of a LogEvent that has been serialized with the 
> Log4jLogEvent.serialize method fails after the serialized object went through 
> a byte stream.
> Here is a test that demonstrates the issue:
> https://github.com/nucatus/LogEventSerializationPOC



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

-
To unsubscribe, e-mail: log4j-dev-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-dev-h...@logging.apache.org