how to debug or log info in bean | Community
Skip to main content
Xena_bcn
New Participant
October 16, 2015
Solved

how to debug or log info in bean

  • October 16, 2015
  • 34 replies
  • 7521 views

hello here.

So one of my component java bean functions is not returning result I am expecting.

I added log.info  to trace , doesn't print anything.

 

Then used debug from Eclipse , doesn't stop on breakpoints.

 

Where and what I should do?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by edubey

Try this snippet of code.

Resource r = resourceResolver.getResource(path); Asset a = r.adaptTo(Asset.class); Rendition rnd = a.getOriginal(); long size = rnd.getSize();

34 replies

smacdonald2008
New Participant
October 16, 2015

What file are you looking in? 

Employee
October 16, 2015

So the bundle that contains your java code is empty?

Did you follow the guide[1] for adding Java classes to your OSGI bundle? It seems like your maven file has not been configured correctly to include the java class. After building you bundle, you should be able to unpack the jar file and see your class file.

Regards,

Opkar

[1] https://helpx.adobe.com/experience-manager/using/creating-osgi-bundles-digital-marketing.html

Xena_bcn
Xena_bcnAuthor
New Participant
October 16, 2015

oh not mine was:

private final Logger log = LoggerFactory.getLogger(getClass());

 

I added this, compiled and deployed. but it is still not writing log.

should i restart?

Xena_bcn
Xena_bcnAuthor
New Participant
October 16, 2015

Hi,

It is one of components Java bean class.

I access to the web page via WCM in localhost:4502 and I see the component, but the file size is shown as 0.00kb

ButI don't see any log.

I've  used System.out.println("") too.

Employee
October 16, 2015

Hi,

unless I have missed it, you haven't explained how you are expecting your code to be called? Is it called by a JSP, is it called by another Java OSGI Service?

Regards,

Opkar

Xena_bcn
Xena_bcnAuthor
New Participant
October 16, 2015

all logs in author\crx-quickstart\logs folder

Xena_bcn
Xena_bcnAuthor
New Participant
October 16, 2015

hellooo

before the calling the private method it is printing it

 

why?

Xena_bcn
Xena_bcnAuthor
New Participant
October 16, 2015

hi

My Java class is working fine

all other info of this component is shown correctly...

Xena_bcn
Xena_bcnAuthor
New Participant
October 16, 2015

Hi, thank you for trying to help me

 

here is a screenshot [img]logging.png[/img]

edubey
New Participant
October 16, 2015

This doesn't look like you are calling the method, its just creating a bean object and setting the property.

Here's what I think, you are using getter setter method in you bean class.

Getter method should only return the value, where as to set value to some instance object you should use setter method. but in this case you are passing arguments to getter method which doesn't seems to be a good one. Please have a setter method to set the value of URL instance variable and then use below code

<c:set var="filesize"  value="${ouritem.fileSize}"/> <c:out value="${filesize}"/>