Not tested

$user =& JFactory::getUser();
if ($user->guest) {
echo "<a href='/login'>Login</a>";
} else {
$userToken = JSession::getFormToken();
echo "Logged in as: ". $user->username . ". ";
echo "<a href='/index.php?option=com_users&task=user.logout&" . $userToken . "=1'>Logout</a>";
}

 Working (not tested by me)

<?php if (!JFactory::getUser()->guest): ?>
	<li class="maximenuck">
	<a href="/index.php?option=com_users&task=user.logout&<?php echo JSession::getFormToken(); ?>=1">Logout</a>
	</li>
<?php endif; ?>